ShapeRange.ParentGroup 属性 (Excel)

返回一个 Shape 对象,该对象代表子形状或子形状范围的通用父形状。

语法

表达式ParentGroup

表达 一个代表 ShapeRange 对象的变量。

示例

在此示例中,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

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。