Returning an Object from a Collection

Aa433258.vs_note(en-us,office.12).gif  Note
The use of CommandBars in some Microsoft Office applications has been superseded by the new Ribbon user interface. For more information, search help for the keyword "Ribbon."

The Item property returns a single object from a collection. The following example sets the cmdbar variable to a CommandBar object that represents the first command bar in the CommandBars collection.

  Set cmdbar = CommandBars.Item(1)

The Item property is the default property for most collections, so you can write the same statement more concisely by omitting the Item keyword.

  Set cmdbar = CommandBars(1)

For more information about a specific collection, see the Help topic for the collection or the Item property for the collection.

See Also