I was wondering if there was code to disable all of the menu items on a form, instead of having to go through each one and setting them to disabled manually.
Thanks
Printable View
I was wondering if there was code to disable all of the menu items on a form, instead of having to go through each one and setting them to disabled manually.
Thanks
'
Option Explicit
'
Public Sub MenuDis()
'
'mycontrol = control and increment is increment for forms
'some situtations use more than one form.
'
Dim ctlMyControl As Control
Dim intIncrement As Integer
'
For intIncrement = 0 To Forms.Count - 1
For Each ctlMyControl In Forms(intIncrement).Controls
'
If TypeOf ctlMyControl Is Menu Then
'
ctlMyControl.Enabled = False
'
End If
'
Next ctlMyControl
'
Next intIncrement
'
End Sub
'
'========================================================================
'========================================================================
Private Sub Command1_Click()
Call MenuDis
End Sub
You can use a For Each Loop. Make a CommandButton and put the Following code in it. This code will Loop through all of the Objects on the Form and if there is a Menu, it will be disabled.
Code:Dim Obj As Object
' Loop through all controls
For Each Obj In Controls
' If the object is a Menu then disable it
If TypeOf Obj Is Menu Then
Obj.Enabled = False
End If
Next Obj
I have'nt found anything easy yet. I wrote 2 subs. 1 called DisableMnuItems and 1 called EnableMnuItems and just made a call to these subs whenever. Manually sux!
..later
Thanks everybody I got it working.
Here is a question for you Megatron. How would you dim or disable foreign application menus?
Thanks!