Class ChartCategory (Word VBA)

The class ChartCategory represents all chart categories in the document, whether visible (unfiltered) or not.


To use a ChartCategory class variable it first needs to be instantiated, for example

Dim chrc as ChartCategory
Set chrc = ActiveDocument.Background.Chart.ChartGroups(1).CategoryCollection(Index:=1)

The following procedures can be used to set variables of type ChartCategory: ChartGroup.CategoryCollection and CategoryCollection.Item

For Each

Here is an example of processing the ChartCategory items in a collection.

Dim chrcCategoryCollection As ChartCategory
For Each chrcCategoryCollection In ActiveDocument.Background.Chart.ChartGroups(1).CategoryCollection()
Next chrcCategoryCollection


Returns a Long that represents the number of categories in the collection.

Dim lngCount As Long
lngCount = ActiveDocument.Background.Chart.ChartGroups(1).CategoryCollection.Count


Returns an individual chart category.

Syntax : expression.Item (Index)

Index: The name or index number for the object.

Dim chrcCategoryCollection As ChartCategory
Set chrcCategoryCollection = ActiveDocument.Background.Chart.ChartGroups(1).CategoryCollection(Index:=1)


Returns an object that represents the parent object of the specified CategoryCollection object.

Dim objParent As Object
Set objParent = ActiveDocument.Background.Chart.ChartGroups(1).CategoryCollection.Parent


Returns or sets a Boolean that determines whether the specified chart category is filtered out from the chart.

ActiveDocument.Background.Chart.ChartGroups(1).CategoryCollection(1).IsFiltered = True


Returns or sets a String that represents the name of a chart category.

Dim strName As String
strName = ActiveDocument.Background.Chart.ChartGroups(1).CategoryCollection(1).Name


Returns an object that represents the parent object of the specified ChartCategory object.

Dim objParent As Object
Set objParent = ActiveDocument.Background.Chart.ChartGroups(1).CategoryCollection(1).Parent