傳回一個物件,該物件代表一個數列 (Series 物件) ,或表示數列集合 () 圖表或圖表群組中的 SeriesCollection 物件。
語法
運算式。SeriesCollection (索引)
expression 代表 Chart 物件的變數。
參數
| 名稱 | 必要/選用 | 資料類型 | 描述 |
|---|---|---|---|
| Index | 選用 | Variant | 數列的名稱或索引號碼。 如果未指定 Index,SeriesCollection 方法會傳回圖表中的所有數列。 |
| Index | 選用 | 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
另請參閱
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。