Adds a list item to the specified command bar combo box control . The combo box control must be a custom control and must be a drop-down list box or a combo box.

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."
Note
This method will fail if it's applied to an edit box or a built-in combo box control.

Syntax

expression.AddItem(Text, Index)

expression A variable that represents a CommandBarComboBox object.

Parameters

Name Required/Optional Data Type Description
Text Required String The text added to the control.
Index Optional Variant The position of the item in the list. If this argument is omitted, the item is added to the end of the list.

Example
This example adds a combo box control to a command bar. Two items are added to the control, and the number of line items and the width of the combo box are set.

Visual Basic for Applications
Set myBar = CommandBars("Custom") Set myControl = myBar.Controls.Add(Type:=msoControlComboBox, Id:=1) With myControl .AddItem "First Item", 1 .AddItem "Second Item", 2 .DropDownLines = 3 .DropDownWidth = 75 .ListHeaderCount = 0 End With
add add a list item to a specified command bar list box add an item to a combo box list add item add item method additem AddItem Method apply an item to a combo box control ofv select an list item to be added to the command bar

See also: