返回一个 Shape 对象,该对象代表子图形或子图形区域的公共父图形。
expression.ParentGroup
expression 必需。该表达式返回“应用于”列表中的对象之一。
在本示例中,Microsoft Excel 向活动工作表添加两个图形,然后通过删除组合的父图形来删除这两个图形。
Sub ParentGroup()
Dim pgShape As Shape
With ActiveSheet.Shapes
.AddShape Type:=1, Left:=10, Top:=10, _
Width:=100, Height:=100
.AddShape Type:=2, Left:=110, Top:=120, _
Width:=100, Height:=100
.Range(Array(1, 2)).Group
End With
' Using the child shape in the group get the Parent shape.
Set pgShape = ActiveSheet.Shapes(1).GroupItems(1).ParentGroup
MsgBox "The two shapes will now be deleted."
' Delete the parent shape.
pgShape.Delete
End Sub