» Change the state of a custom CommandBar button 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
The macro below shows how you can change the state of a custom CommandBar button so it displays as depressed or not.
Sub ToggleButtonState()
Dim m As CommandBarControl
Set m = CommandBars("CommandBarName").Controls(1)
If m.State = msoButtonDown Then
m.State = msoButtonUp
Else
m.State = msoButtonDown
End If
Set m = Nothing
End Sub
Book Store:
Recommended Books:
- Mastering Excel 2000 (for beginner)
- Treason: Liberal Treachery from the Cold War to the War on Terrorism
- Marketing Plans That Work, Targeting Growth and Profitability
- Fish! A Remarkable Way to Boost Morale and Improve Results
- The South Beach Diet: The Delicious, Doctor-Designed, Foolproof Plan for Fast and Healthy Weight Loss
- Absolute Beginner's Guide to Microsoft Excel 2002
No comments have been submitted.

