Displaying or Hiding Toolbars

A toolbar takes up screen space that could otherwise be used to display data; you can display a toolbar when necessary and hide it when the user no longer needs it. A toolbar is visible if its Visible property is True, and it isn't visible if this property is False. Setting this property to True corresponds to selecting the check box next to the name of the toolbar in the Toolbars dialog box and then clicking OK.

For example, the following procedure, assigned to the View MyToolbar menu item on the View menu, toggles the value of the Checked property of the menu item and the visible property of the toolbar every time the user clicks the menu item. When the toolbar is made visible, it reappears in the same position it occupied when it was made invisible.


Sub ViewMyAppToolbar()
    With MenuBars(xlWorksheet).Menus("View").MenuItems("View MyToolbar")
        .Checked = Not .Checked
        Toolbars("MyAppTools").Visible = .Checked
    End With
End Sub

When a toolbar is visible, the user can click any toolbar button on it to run that button's assigned procedure.