共用方式為


PowerPoint) (Shape.ParentGroup 屬性

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

語法

運算式ParentGroup

表達 代表 Shape 物件的變數。

傳回值

圖形

範例

本範例會在使用中簡報的第一張投影片上建立兩個圖案,並將這些圖案分組;然後在群組中使用一個圖形,存取父群組,並以相同的填滿色彩填滿父群組中的所有圖形。 本範例假設使用中簡報的第一張投影片目前不包含任何圖案。 如果是,您會收到錯誤。

Sub ParentGroup()

    Dim sldNewSlide As Slide
    Dim shpParentGroup As Shape

    'Add two shapes to active document and group

    Set sldNewSlide = ActivePresentation.Slides _
        .Add(Index:=1, Layout:=ppLayoutBlank)

    With sldNewSlide.Shapes

    	.AddShape Type:=msoShapeBalloon, Left:=72, _
            Top:=72, Width:=100, Height:=100

        .AddShape Type:=msoShapeOval, Left:=110, _
            Top:=120, Width:=100, Height:=100

        .Range(Array(1, 2)).Group

    End With

    Set shpParentGroup = ActivePresentation.Slides(1).Shapes(1) _
        .GroupItems(1).ParentGroup

    shpParentGroup.Fill.ForeColor.RGB = RGB _
        (Red:=151, Green:=51, Blue:=250)

End Sub

另請參閱

Shape 物件

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應