April 2006
Beginner
1114 pages
98h 16m
English
commandbarcombobox.AddItem(Text, [Index])
Adds an item to the control’s list.
|
Argument |
Settings |
|---|---|
|
|
The item to add to the list. |
|
|
The position of the item in the list. The default is to insert the new item at the end of the list. |
The following code creates a new drop-down list on the worksheet menu bar and adds three items to the list:
Sub AddDropDown( )
Dim cb As CommandBar, cbo As CommandBarComboBox
' Get a command bar
Set cb = CommandBars("Worksheet Menu Bar")
' Create the combo box.
Set cbo = cb.Controls.Add(msoControlDropdown, , , , True)
' Add a Tag so this control can be found from other code.
cbo.Tag = "cboSelectText"
' Add items.
cbo.AddItem "This"
cbo.AddItem "That"
cbo.AddItem "the"
cbo.AddItem "other"
' Set the procedure to run.
cbo.OnAction = "ShowSelection"
End SubRead now
Unlock full access