Returning an Object from a Collection

Microsoft Office Visual Basic

Returning an Object from a Collection

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.