Returning an Object from a Collection

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

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.