Dim mnu As Object
For Each mnu In Me.Controls
    If TypeName(mnu) = "Menu" Then
       mnu.Enabled = True
    End If
Next

解决方案 »

  1.   

    谢谢大家,非常感谢,特别是cooly
      

  2.   

    我重新写了条件语句,这样就可以了
    Dim mnu As Object
    For Each mnu In Me.Controls
        If TypeName(mnu) = "Menu" Then
           If mnu.Caption = "-" Then
            GoTo a
           End If
           mnu.Enabled = False
        End If
    a:
    Next
      

  3.   

    加一个判断Dim mnu As Object
    For Each mnu In Me.Controls
        If TypeName(mnu) = "Menu" Then
           If Trim(mnu.Caption) <> "-" Then
              mnu.Enabled = False
           End If
        End If
    Next
      

  4.   

    TO wangtao301301301(涛大):在程序中,不到万不得已,不要使用GOTO.