Class SeriesCollection (Word VBA)

The class SeriesCollection represents a collection of all the Series objects in the specified chart or chart group. To use a SeriesCollection class variable it first needs to be instantiated, for example


Dim scn as SeriesCollection
Set scn = ActiveDocument.Background.Chart.SeriesCollection()

Add

Adds one or more new series to the collection.

This method does not actually return a Series object as stated in the Object Browser.

Add (Source, Rowcol, SeriesLabels, CategoryLabels, Replace)


With ActiveDocument.InlineShapes(1) 
 If .HasChart Then 
 .Chart.SeriesCollection.Add _ 
 Source:="Sheet1!B1:B10" 
 End If 
End With

Arguments

The following argument is required

Source (Source) - The new data as a string representation of a range contained in the Workbook property of the ChartData object for the chart.

Optional arguments

The following arguments are optional

Rowcol (XlRowCol) - One of the enumeration values that specifies whether the new values are in the rows or columns of the specified range.

Possible return values are xlColumns - The data series is in a row, xlRows - The data series is in a column.

SeriesLabels (Boolean) - True if the first row or column contains the name of the data series. False if the first row or column contains the first data point of the series. If this argument is omitted, Microsoft Word attempts to determine the location of the series name from the contents of the first row or column.

CategoryLabels (Boolean) - True if the first row or column contains the name of the category labels. False if the first row or column contains the first data point of the series. If this argument is omitted, Word attempts to determine the location of the category label from the contents of the first row or column.

Replace (Boolean) - If CategoryLabels is True and Replace is True, the specified categories replace the categories that currently exist for the series. If Replace is False, the existing categories will not be replaced. The default is False.

Count

Returns the number of objects in the collection.


Dim lngCount As Long
lngCount = ActiveDocument.Background.Chart.SeriesCollection.Count

Extend

Adds new data points to an existing series collection.

This method is not available for PivotChart reports.

Extend (Source, Rowcol, CategoryLabels)


With ActiveDocument.InlineShapes(1) 
 If .HasChart Then 
 .Chart.SeriesCollection.Extend _ 
 Source:="B1:B6" 
 End If 
End With

Arguments

The following argument is required

Source (Source) - The new data to be added to the SeriesCollection object, represented as an A1-style range reference.

Optional arguments

The following arguments are optional

Rowcol (XlRowCol) - One of the XlRowCol enumeration values that specifies whether the new values are in the rows or columns of the given range source. If this argument is omitted, Microsoft Word attempts to determine where the values are by the size and orientation of the selected range or by the dimensions of the array.

Possible return values are xlColumns - The data series is in a row, xlRows - The data series is in a column.

CategoryLabels (Boolean) - True to have the first row or column contain the name of the category labels. False to have the first row or column contain the first data point of the series. If this argument is omitted, Word attempts to determine the location of the category label from the contents of the first row or column.

Item

Returns a single Series object from the collection.

Item (Index)

Index: The name or index number for the object.


With ActiveDocument.InlineShapes(1) 
 If .HasChart Then 
 With .Chart.SeriesCollection.Item(1).Trendlines.Item(1) 
 .Forward = 5 
 .Backward = .5 
 End With 
 End If 
End With 

NewSeries

Creates a new series.

This method is not available for PivotChart charts.


With ActiveDocument.InlineShapes(1) 
 If .HasChart Then 
 Set ns = .Chart.SeriesCollection.NewSeries 
 End If 
End With