CommandBarComboBox.List property (Office)

Gets or sets an item in the CommandBarComboBox control. Read/write.

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, see Overview of the Office Fluent ribbon.

Syntax

expression.List (Index)

expression A variable that represents a CommandBarComboBox object.

Parameters

Name Required/Optional Data type Description
Index Required Integer The list item to be set.

Remarks

This property is read-only for built-in combo box controls.

Example

This example checks the fourth list item in the combo box control whose caption is Stock Data on the command bar named Custom. If the item isn't "View News," the example displays a message advising the user that the combo box may be damaged and asks the user to reinstall the application.

Set myBar = CommandBars _ 
    .Add(Name:="Custom", Position:=msoBarTop, _ 
    Temporary:=True) 
With myBar 
    .Controls.Add Type:=msoControlComboBox, ID:=1 
    .Visible = True  
End With 
With CommandBars("Custom").Controls(1) 
    .AddItem "Get Stock Quote", 1 
    .AddItem "View Chart", 2 
    .AddItem "View Fundamentals", 3 
    .AddItem "View News", 4 
    .Caption = "Stock Data" 
    .DescriptionText = "View Data For Stock" 
End With 
If CommandBars("Custom").Controls(1).List(4) _ 
     > "View News" Then 
MsgBox ("Stock Data appears to be damaged." & _ 
     " Please reinstall application.") 
End If

See also

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.