Represents a button control on a command bar.

Note
The use of CommandBars in some Microsoft Office applications has been superseded by the new Ribbon user interface. For more information, search help for the keyword "Ribbon."

Example

Use Controls(index), whereis the index number of the control, to return a CommandBarButtonobject. Note that the Typeproperty 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.

Visual Basic for Applications
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
Note
You can also use the FindControl method to return a CommandBarButton object.
change style of a command bar button Command Bar Button Object CommandBarButton commandbarbutton object find a command bar button object ofv select a button for a command bar object use a button control object on a command bar

See also:

index