A collection of CommandBarControl objects that represent the command bar controls 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 the Controls property to return the CommandBarControls collection. 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.

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

Use the Add method to add a new command bar control to the CommandBarControls collection. This example adds a new, blank button to the command bar named "Custom."

Visual Basic for Applications
Set myBlankBtn = CommandBars("Custom").Controls.Add

Use Controls(index), whereis the caption or index number of a control, to return a CommandBarControl, CommandBarButton, CommandBarComboBox, or CommandBarPopupobject. The following example copies the first control from the command bar named "Standard" to the command bar named "Custom."

Visual Basic for Applications
Set myCustomBar = CommandBars("Custom") Set myControl = CommandBars("Standard").Controls(1) myControl.Copy Bar:=myCustomBar, Before:=1
add a new command bar control to the collection Command Bar Controls Collection Object CommandBarControl Collection commandbarcontrol collection object display all objects of the command bar controls ofv view the collection of command bar control objects

See also:

index