以自訂報表表示一組 Shape 物件。
範例
使用 Report.Shapes 屬性來取得 Shapes 集合物件。 以下範例中,報告必須是主動視圖才能取得 Shapes 集合;否則,執行時錯誤 424 (Object 需要) For Each oShape In oReport.Shapes 。
Sub ListShapesInReport()
Dim oReports As Reports
Dim oReport As Report
Dim oShape As shape
Dim reportName As String
Dim msg As String
Dim msgBoxTitle As String
Dim numShapes As Integer
numShapes = 0
msg = ""
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)
msgBoxTitle = "Shapes in report: '" & oReport.Name & "'"
For Each oShape In oReport.Shapes
numShapes = numShapes + 1
msg = msg & numShapes & ". Shape type: " & CStr(oShape.Type) _
& ", '" & oShape.Name & "'" & vbCrLf
Next oShape
If numShapes > 0 Then
MsgBox Prompt:=msg, Title:=msgBoxTitle
Else
MsgBox Prompt:="This report contains no shapes.", _
Title:=msgBoxTitle
End If
Else
MsgBox Prompt:="The requested report, '" & reportName _
& "', does not exist.", Title:="Report error"
End If
End Sub
方法
| 名稱 |
|---|
| AddCallout |
| AddChart |
| AddConnector |
| AddCurve |
| AddLabel |
| AddLine |
| AddPolyline |
| AddShape |
| AddTable |
| AddTextbox |
| AddTextEffect |
| BuildFreeform |
| 項目 |
| Range |
| SelectAll |
屬性
| 名稱 |
|---|
| Background |
| Count |
| Default |
| Parent |
| 值 |
另請參閱
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。