Change the availability for a menu item

 2000-02-05    Commandbars    0    58

The macro below shows how you can toggle the availability state for a menu item:

Sub ToggleMenuControls()
Dim m As CommandBarControl, mi As CommandBarControl
    Set m = CommandBars.FindControl(ID:=30002) ' File Menu
    If m Is Nothing Then Exit Sub
    For Each mi In m.Controls
        If mi.ID = 18 Then mi.Enabled = Not mi.Enabled 
        ' toggles the state for the Print menu
    Next mi
    Set mi = Nothing
    Set m = Nothing
End Sub
The CommandBars Tools available for download will help you to find the ID numbers of the built-in CommandBars.