Table of contents
TOC
Collapse the table of content
Expand the table of content

CommandBarComboBox.AddItem Method (Office)

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

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 component of the Microsoft Office Fluent user interface. For more information, search Help for the keyword "ribbon."

Syntax

expression. AddItem( Text, Index )

expression A variable that represents a CommandBarComboBox object.

Parameters

NameRequired/OptionalData TypeDescription
TextRequiredStringThe text added to the control.
IndexOptionalVariantThe 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.

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

Note

Note This method will fail if it's applied to an edit box or a built-in combo box control.

See also

Concepts

CommandBarComboBox Object

Other resources

CommandBarComboBox Object Members

© 2018 Microsoft