Project) (Report.Shapes 屬性

取得報表中 圖形 物件的集合。 唯讀 的圖形 。

語法

運算式。圖形

運算式 代表 'Report' 物件的變數。

範例

下列範例會列出自訂報表中的圖形。 報表必須是使用中的檢視,才能取得 [圖形 ] 集合;否則,您會在陳述式中 For Each oShape In oReport.Shapes 收到執行階段錯誤 424 (Object required) 。

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 = "New 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

屬性值

圖形

另請參閱

報表物件、圖形、物件

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。