State Property Example

This example creates a command bar named “Custom” and adds two blank buttons to it. The example then sets the button on the left to msoButtonUp and sets the button on the right to msoButtonDown.

Set myBar = CommandBars _
    .Add(Name:="Custom", Position:=msoBarTop, _
    Temporary:=True)
With myBar
    .Controls.Add Type:=msoControlButton, ID:=1
    .Controls.Add Type:=msoControlButton, ID:=1
    .Visible = True
End With
Set myControl1 = CommandBars("Custom").Controls(1)
myControl1.State = msoButtonUp
Set myControl2 = CommandBars("Custom").Controls(2)
myControl2.State = msoButtonDown