RemoveItem Method

Applies To

CommandBarComboBox object.

Description

Removes a list item from the specified command bar combo box control.

Note   The property fails when applied to controls other than list controls.

Syntax

expression.RemoveItem(Index)

expression Required. An expression that returns a CommandBarComboBox object.

Index Required Long. The item to be removed from the list.

Example

The following example determines whether there are more than three items in the combo box control named "Combo1" on the custom command bar named "Custom." If there are more than three items, the example removes the second item, alters the style to not show the combo box label, and sets a new value. It also sets the Tag property of the parent object (the CommandBarControl object) to show that the list has changed.

Set myBar = CommandBars("Custom")
Set myControl = myBar.Controls("Combo1")
With myControl
    If .ListCount > 3 Then
        .RemoveItem 2
        .Style = msoComboNormal
        .Text = "New Default"
        Set ctrl = .Parent
        ctrl.Tag = "Contents Changed"
    End If
End With