CommandBarControl Object
Office Developer Reference |
Office Developer ReferenceRepresents 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 see, 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(
index
), where
index
is the index number of a control, to return a CommandBarControl object. (The Type property of the control must be msoControlLabel, msoControlExpandingGrid, msoControlSplitExpandingGrid, msoControlGrid, or msoControlGauge). Variables declared as CommandBarControl can be assigned CommandBarButton, CommandBarComboBox, and CommandBarPopup values.
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 variable
lbl
represents a CommandBarControl object.
Object Model ReferenceCommandBarControl Object Members
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