title | keywords | f1_keywords | ms.service | ms.assetid | ms.date | ms.localizationpriority | |
---|---|---|---|---|---|---|---|
Chart.SeriesCollection method (Project) |
vbapj.chm131631 |
|
project-server |
fb4fea11-3dac-73f9-6566-6c81de0888e7 |
06/08/2017 |
medium |
Returns an object that represents either one series (a Series object) or a collection of the series (a SeriesCollection object) in the chart or chart group.
expression.SeriesCollection (Index)
expression A variable that represents a Chart object.
Name | Required/Optional | Data type | Description |
---|---|---|---|
Index | Optional | Variant | The name or index number of the series. If Index is not specified, the SeriesCollection method returns all of the series in the chart. |
Index | Optional | Variant |
Object
To get a single series, specify the Index parameter. The following example prints the first value of the "Actual Work" series. The first call to the SeriesCollection method gets the collection of all the series in the chart. The second call to the SeriesCollection method gets one specific series.
Sub GetSeriesValue()
Dim reportName As String
Dim theReportIndex As Integer
Dim theChart As Chart
Dim seriesInChart As SeriesCollection
Dim chartSeries As Series
reportName = "Simple scalar chart"
If (ActiveProject.Reports.IsPresent(reportName)) Then
' Make the report active.
theReportIndex = ActiveProject.Reports(reportName).Index
ActiveProject.Reports(theReportIndex).Apply
Set theChart = ActiveProject.Reports(theReportIndex).Shapes(1).Chart
Set seriesInChart = theChart.SeriesCollection
If (seriesInChart.Count > 1) Then
Set chartSeries = theChart.SeriesCollection("Actual Work")
Debug.Print "Value of the Actual Work series, for task " & chartSeries.XValues(1) _
& ": " & chartSeries.Values(1)
End If
End If
End Sub
For example, running the GetSeriesValue macro on a chart that includes a plot of actual work for tasks, could have the following output: Value of the Actual Work series, for task T1: 16
[!includeSupport and feedback]