项目) (Shapes 对象
表示自定义报表中 Shape 对象的集合。
使用 Report.Shapes 属性获取 Shapes 集合对象。 在以下示例中,报表必须是活动视图才能获取 Shapes 集合;否则,会出现运行时错误 424, (语句中 For Each oShape In oReport.Shapes
需要) Object。
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 |
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。