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

CommandBarButton.Id Property (Office)

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

Gets the ID for a built-in CommandBarButton control. Read-only.

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."


expression. Id

expression Required. A variable that represents a CommandBarButton object.


A control's ID determines the built-in action for that control. The value of the Id property for all custom controls is 1.


This example changes the button face of the first control on the command bar named "Custom2" if the button's ID value is less than 25.

Set ctrl = CommandBars("Custom").Controls(1) 
With ctrl 
    If .Id < 25 Then 
        .FaceId = 17 
        .Tag = "Changed control" 
    End If 
End With

The following example changes the caption of every control on the toolbar named "Standard" to the current value of the Id property for that control.

For Each ctl In CommandBars("Standard").Controls 
    ctl.Caption = CStr(ctl.Id) 
Next ctl

See also


CommandBarButton Object

Other resources

CommandBarButton Object Members

© 2018 Microsoft