Represents a command bar control. The CommandBarControl object is a member of the CommandBarControls collection. The properties and methods of the CommandBarControl object are all shared by the CommandBarButton, CommandBarComboBox, and CommandBarPopup objects.

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

Remarks

When writing Visual Basic code to work with custom command bar controls, you use the CommandBarButton, CommandBarComboBox, and CommandBarPopup objects. When writing code to work with built-in controls in the container application that cannot be represented by one of those three objects, you use the CommandBarControl object. Use Controls(), where is the index number of a control, to return a CommandBarControlobject. (The Typeproperty of the control must be msoControlLabel, msoControlExpandingGrid, msoControlSplitExpandingGrid, msoControlGrid, or msoControlGauge). Variables declared as CommandBarControlcan be assigned CommandBarButton, CommandBarComboBox, and CommandBarPopupvalues.

Example

You can also use the FindControl method to return a CommandBarControl object. The following example searches for a control of type msoControlGauge; if it finds one, it displays the index number of the control and the name of the command bar that contains it. In this example, the variablerepresents a CommandBarControlobject.

Visual Basic for Applications
Set lbl = CommandBars.FindControl(Type:= msoControlGauge) If lbl Is Nothing Then MsgBox "A control of type msoControlGauge was not found." Else MsgBox "Control " & lbl.Index & " on command bar " _ & lbl.Parent.Name & " is type msoControlGauge" End If
Command Bar Control Object CommandBarControl commandbarcontrol object display all command bar control objects find command bar control objects ofv write code with built-in controls for a command bar control object

See also:

index index lbl