CommandBarControl Object

Multiple objects
CommandBarControl
CommandBar

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

Using 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.)

Note  Variables declared as CommandBarControl can be assigned CommandBarButton, CommandBarComboBox, and CommandBarPopup values.

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.

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

Properties | Application Property | BeginGroup Property | BuiltIn Property | Caption Property | Creator Property | DescriptionText Property | Enabled Property | Height Property | HelpContextId Property | HelpFile Property | Id Property | Index Property | IsPriorityDropped Property | Left Property | OLEUsage Property | OnAction Property | Parameter Property | Parent Property | Priority Property | Tag Property | TooltipText Property | Top Property | Type Property | Visible Property | Width Property

Methods | Copy Method | Delete Method | Execute Method | Move Method | Reset Method | SetFocus Method

Parent Objects | CommandBarControls Collection | CommandBars Collection

Child Objects | CommandBar Object