Returning an Object from a Collection

Microsoft Office Web Components Object Model

Returning an Object from a Collection

   

The Item property returns a single object from a collection. The following example sets the variable thisChart to a ChChart object that represents chart one.

Set thisChart = ChartWorkspace1.Charts.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 thisChart = ChartWorkspace1.Charts(1)

Some collections use an enumerated type with their Item property to return specific members of the collection. For example, the ChAxes collection uses the ChartAxisPositionEnum enumerated type, as shown in the following example.

Set chConstants = ChartSpace1.Constants
Set valueAxis = ChartSpace1.Charts(0).Axes.Item(chConstants.chAxisPositionLeft)
Set categoryAxis = ChartSpace1.Charts(0).Axes.Item(chConstants.chAxisPositionBottom)

Again, you can omit the Item keyword, as shown in the following example.

Set chConstants = ChartSpace1.Constants
Set valueAxis = ChartSpace1.Charts(0).Axes(chConstants.chAxisPositionLeft)
Set categoryAxis = ChartSpace1.Charts(0).Axes(chConstants.chAxisPositionBottom)

For more information about a specific collection, see the Help topic for that collection.