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

CommandBarComboBox.RemoveItem Method (Office)

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

Removes an item from a CommandBarComboBox control.

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. RemoveItem( Index )

expression A variable that represents a CommandBarComboBox object.

Parameters

NameRequired/OptionalData TypeDescription
IndexRequiredIntegerThe item to be removed from the list.

Example

This example determines whether there are more than three items in the specified combo box. If there are more than three items, the example removes the second item, alters the style, 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 _ 
    .Add(Name:="Custom", Position:=msoBarTop, _ 
    Temporary:=True) 
With myBar 
    .Controls.Add Type:=msoControlComboBox, ID:=1 
    .Visible = True  
End With 
With CommandBars("Custom").Controls(1) 
    .AddItem "Get Stock Quote", 1 
    .AddItem "View Chart", 2 
    .AddItem "View Fundamentals", 3 
    .AddItem "View News", 4 
    .Caption = "Stock Data" 
    .DescriptionText = "View Data For Stock" 
End With 
Set myControl = myBar.Controls(1) 
With myControl 
    If .ListCount > 3 Then 
        .RemoveItem 2 
        .Style = msoComboNormal 
        .Text = "New Default" 
         Set ctrl = .Parent 
    End If 
End With

Note

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

See also

Concepts

CommandBarComboBox Object

Other resources

CommandBarComboBox Object Members

© 2018 Microsoft