Chart.SeriesCollection 方法 (Project)

返回一个 对象,该对象表示一个系列 (一个 Series 对象) ,或者 (图表或图表组中的 SeriesCollection 对象) 的系列集合。

语法

表达式SeriesCollection (Index)

expression:一个表示 Chart 对象的变量。

参数

名称 必需/可选 数据类型 说明
Index 可选 Variant 序列的名称或索引号。 如果未指定 IndexSeriesCollection 方法将返回图表中的所有系列。
"索引" 可选 Variant

返回值

Object

示例

若要获取单个序列,请指定 Index 参数。 以下示例打印“实际工时”系列的第一个值。 对 SeriesCollection 方法的第一次调用获取图表中所有系列的集合。 对 SeriesCollection 方法的第二次调用将获取一个特定的系列。

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

例如,在包含任务实际工时图的图表上运行 GetSeriesValue 宏可能具有以下输出: Value of the Actual Work series, for task T1: 16

另请参阅

Chart 对象

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。