共用方式為


Shape.ParentGroup 屬性 (PowerPoint)

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

語法

表情家長團體

expression 一個用於表示 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 支援與意見反應