ERLANDSEN DATA CONSULTING Excel & VBA Tips   Informasjon på norsk / Information in Norwegian

These pages are no longer updated and are only available for archive purposes.

Click here to visit the pages with updated information.

Change the availability for the CommandBars

With the macro below you can toggle the availability of the Workbook Menu Bar, the Standard toolbar and a custom CommandBar. The first time you run the macro the menu and Standard bar are disabled, the custom toolbar is enabled. The next time you run the macro the menu and the Standard bar are enabled, the custom CommandBar is disabled.

Sub ToggleCommandBars()
Dim cbEnabled As Boolean
    ' get the current commandbar state
    cbEnabled = Not Application.CommandBars(1).Enabled
    ' apply the new state to the Workbook Menu Bar
    Application.CommandBars(1).Enabled = cbEnabled
    ' apply the new state to the Standard toolbar
    Application.CommandBars("StandardOPE").Enabled = cbEnabled
    ' apply the new state to a custom commandbar (the oposite of the previous two)
    Application.CommandBars("MyCustomCommandBar").Enabled = Not cbEnabled
End Sub

 

Document last updated 2000-02-05 12:46:59      Printerfriendly version

 

Erlandsen Data Consulting     http://www.erlandsendata.no/   
Excel & VBA Tips   Copyright ©1999-2017    Ole P. Erlandsen   All rights reserved
E-mail Contact Address