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 WCChart 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 WCAxes collection uses the ChartAxisPositionEnum enumerated type, as shown in the following example.

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

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

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

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