|  

» 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
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


Rate This Tip
12 34 5
Rating: 3.90     Views: 15290
No comments have been submitted.
Click here to post comment
For Registered Users
Name
Comment Title
Comments