» Change the availability for the CommandBars using VBA in Microsoft Excel
VBA macro tip contributed by Erlandsen Data Consulting offering Microsoft Excel Application development, template customization, support and training solutions
CATEGORY - Menus, Toolbars, Status bar in VBA
VERSION - All Microsoft Excel Versions
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
Book Store:
Recommended Books:
- Financial Shenanigans : How to Detect Accounting Gimmicks & Fraud in Financial Reports
- Windows XP All-in-One Desk Reference For Dummies
- Microsoft Office XP Step-By-Step (With CD-ROM)
- Successful Business Planning in 30 Days: A Step-By-Step Guide for Writing a Business Plan and Starting Your Own Business
- Infectious Greed: How Deceit and Risk Corrupted the Financial Markets
- 422 Tax Deductions for Businesses and Self-Employed Individuals : You Get a Raise Every Time You Find a Legitimate Tax Deduction
No comments have been submitted.

