Clear Method

Applies To

CommandBarComboBox object.

Description

Removes all list items from the specified command bar combo box control (drop-down list box or combo box) and clears the text box (edit box or combo box).

Note   This method will fail if it's applied to a built-in command bar control.

Syntax

expression.Clear

expression Required. An expression that returns a CommandBarComboBox object.

See Also

Add method (CommandBarControls collection), AddItem method, CommandBarComboBox object, Enabled property.

Example

This example checks the number of items in the combo box control named "Names" on the command bar named "Custom." If there are more than three items in the list, the example clears the list, adds a new first item to the list, and displays this new item as the default for the combo box control.

Set myBar = CommandBars("Custom Bar")
Set myControl = myBar.Controls("Names")
With myControl
    If .ListCount > 3 Then
        .Clear
        .AddItem Text:="Bendel", Index:=1
        .ListIndex = 1
    End If
End With