傳回代表 Shapes 集合中圖形子集的 ShapeRange 物件。
語法
運算式。範圍 (索引)
expression 代表 Shapes 物件的變數。
參數
| 名稱 | 必要/選用 | 資料類型 | 描述 |
|---|---|---|---|
| Index | 必要 | Variant | 指定要包含在範圍中的一個或多個圖形。 可以是代表圖形索引號碼的整數、代表圖形名稱的字串,或是包含整數或字串的陣列。 |
| Index | 必要 | Variant | |
| 名稱 | 必要/選用 | 資料類型 | 描述 |
傳回值
ShapeRange
由 Index 參數指定的圖形範圍。
註解
注意事項
您可以運用的 Shape 物件的大部分作業也運用包含單一圖案的 ShapeRange 物件。 當在含有多個圖形的 ShapeRange 物件上執行某些作業會產生錯誤。
雖然您可以使用 Range 屬性傳回報表上任意數目的圖形,但使用預設 值 屬性傳回集合中的單一 圖形 會更簡單。 例如, Shapes(1)是比 Shapes.Range(1)簡單。
若要為 Index 參數指定整數或字串陣列,您可以使用 Array 函數。 例如,下列巨集會選取兩個以名稱指定的圖形。
Sub SelectShapeRange()
Dim arShapes() As Variant
Dim oShapeRange As ShapeRange
arShapes = Array("TextBox 4", "TextBox 5")
Set oShapeRange = ActiveProject.Reports("Table Tests").Shapes.Range(arShapes)
oShapeRange.Select
End Sub
範例
如果您建立的報表包含兩個文字方塊,例如上一個程式碼,下列巨集會依索引號碼選取文字方塊,然後在每個文字方塊中新增陰影。
Sub AddShadow2Shapes()
Dim oReports As Reports
Dim oReport As Report
Dim oShapeRange As ShapeRange
Dim reportName As String
Dim arShapes() As Variant
arShapes = Array(3, 4)
reportName = "Table Tests"
Set oReports = ActiveProject.Reports
If (oReports.IsPresent(reportName)) Then
' Make the report the active view.
oReports(reportName).Apply
Set oReport = oReports(reportName)
Set oShapeRange = oReport.Shapes.Range(arShapes)
oShapeRange.Select
oShapeRange.Shadow.Type = msoShadow1
End If
End Sub
另請參閱
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。