Share via


CommandBarButton Object

CommandBars (CommandBar)
Aa190794.parchild(en-us,office.10).gifCommandBarControls (CommandBarControl)
Aa190794.space(en-us,office.10).gifAa190794.parmult(en-us,office.10).gifCommandBarButton
Aa190794.space(en-us,office.10).gifAa190794.parmult(en-us,office.10).gifCommandBarComboBox
Aa190794.space(en-us,office.10).gifAa190794.parchild(en-us,office.10).gifCommandBarPopup

Represents a button control on a command bar.

Using the CommandBarButton Object

Use Controls(index), where index is the index number of the control, to return a CommandBarButton object. (The Type property of the control must be msoControlButton.)

Assuming that the second control on the command bar named "Custom" is a button, the following example changes the style of that button.

  Set c = CommandBars("Custom").Controls(2)
With c
If .Type = msoControlButton Then
    If .Style = msoButtonIcon Then
        .Style = msoButtonIconAndCaption
    Else
        .Style = msoButtonIcon
    End If
End If
End With

You can also use the FindControl method to return a CommandBarButton object.