Name

commandbar.Enabled [= setting]

Synopsis

True includes the toolbar in the toolbars list; False removes the toolbar from the list. Default is True. To see a list of toolbars, right-click on a command bar.

Removing the toolbar from the toolbar list hides the toolbar and prevents the user from displaying it. The following code demonstrates the Enabled property by turning the Visual Basic toolbar off and on:

' Turn Visual Basic toolbar on/off.
Sub VBToolbarOnOff( )
    ' First, display the toolbar.
    CommandBars("Visual Basic").Visible = True
    ' Switch Enabled on/off.
    CommandBars("Visual Basic").Enabled = Not _
      CommandBars("Visual Basic").Enabled
End Sub

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.