|  

» Change the availability for a menu item using VBA in Microsoft Excel

VBA macro tip contributed by Erlandsen Data Consulting offering Microsoft Excel Application development, template customization, support and training solutions
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





Rate This Tip
12 34 5
Rating: 3.06     Views: 22763
Fine, but...
Antti  Posted on: 31-12-1969
...how do i disable print commands and buttons from menu and toolbars? The above disabled command File -> new.
Name
Comment Title
Comments