返回一个 Shape 对象,该对象代表子图形或子图形范围的普通父图形。
expression.ParentGroup
expression 必需。该表达式返回“应用于”列表中的一个对象。
本示例在活动文档中创建两个图形并对其进行分组。然后利用一个图形访问该组的父级别组,并使用同样的填充颜色填充父级别组中的所有图形。本示例假定活动文档当前并不包括图形,如果包括图形,则产生错误。
Sub ParentGroupShape()
Dim pgShape As Shape
'Add two shapes to active document and group
With ActiveDocument.Shapes
.AddShape Type:=msoShapeOval, Left:=72, _
Top:=72, Width:=100, Height:=100
.AddShape Type:=msoShapeHeart, Left:=110, _
Top:=120, Width:=100, Height:=100
.Range(Array(1, 2)).Group
End With
Set pgShape = ActiveDocument.Shapes(1) _
.GroupItems(1).ParentGroup
pgShape.Fill.ForeColor.RGB = RGB(Red:=100, Green:=0, Blue:=255)
End Sub