共用方式為


Shape.ParentGroup 屬性 (Excel)

會傳回 Shape 物件,代表某個子圖案或某個範圍內所有子圖案的共同父圖案。

語法

表達。家長群組

expression 一個用於表示 Shape 物件的變數。

範例

在本範例中,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 支援與意見反應