更改在Excel中使用VBA自定义命令栏按钮的状态
下面的宏显示了如何更改自定义CommandBar按钮的状态,以使其显示为按下状态或不按下状态。
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