This documentation is archived and is not being maintained.

CommandBarButton Object

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.


CommandBars collection (CommandBar object)
Aa831762.parchild(en-us,office.10).gifCommandBarControls collection (CommandBarControl object),office.10).gifAa831762.parmult(en-us,office.10).gifCommandBarButton object,office.10).gifAa831762.parmult(en-us,office.10).gifCommandBarComboBox object,office.10).gifAa831762.parchild(en-us,office.10).gifCommandBarPopup object

Represents a on a .

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
        .Style = msoButtonIcon
    End If
End If
End With

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