Table of contents
TOC
Collapse the table of content
Expand the table of content

CommandBarButton Object (Office)

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

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 component of the Microsoft Office Fluent user interface. For more information, search Help for the keyword "ribbon."

Example

Use Controls(index), where index is the index number of the control, to return a CommandBarButton object. Note that 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

Note

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

See also

Concepts

Object Model Reference

Other resources

CommandBarButton Object Members

© 2018 Microsoft