获取 ShapeRange 集合中的单个 Shape 对象。 只读 形状。
语法
表达式。值
表达式 表示 'ShapeRange' 对象的变量。
备注
值 是 ShapeRange 对象的默认属性。
示例
以下示例创建名为“测试报告”的报表,创建两个形状,然后将这些形状添加到 一个 ShapeRange 对象。 以 开 sRange.Value(1) 头的语句获取形状范围内的第一个形状。 以 开 sRange(2) 头的语句调用默认的 Value 属性并获取形状范围内的第二个形状。
Sub TestShapeRangeValue()
Dim theReport As Report
Dim textShape1 As shape
Dim textShape2 As shape
Dim reportName As String
Dim sRange As ShapeRange
reportName = "Test Report"
Set theReport = ActiveProject.Reports.Add(reportName)
Set textShape1 = theReport.Shapes.AddTextbox(msoTextOrientationHorizontal, 30, 50, 350, 80)
textShape1.Name = "Text box 1"
Set textShape2 = theReport.Shapes.AddTextbox(msoTextOrientationHorizontal, 30, 130, 350, 80)
textShape2.Name = "Text box 2"
Set sRange = theReport.Shapes.Range(Array("Text box 1", "Text box 2"))
sRange.TextFrame2.AutoSize = msoAutoSizeShapeToFitText
sRange.Value(1).TextFrame2.TextRange.Text = "This is a test. It's only a test."
sRange(2).TextFrame2.TextRange.Text = "This is text box 2."
End Sub
属性值
SHAPE
另请参阅
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。