GroupShapes 集合对象

         
Shapes (Shape)
GroupShapes (Shape)

代表成组的图形中的单个图形。每个图形由一个 Shape 对象表示。使用该对象的 Item 方法可以不必先将它们拆开就可以对组中的单个图形进行操作。

GroupShapes 集合的用法

使用 GroupItems 属性可返回 GroupShapes 集合。使用 GroupItems(index)(此处 index 是成组图形中单个图形的编号)可返回 GroupShapes 集合中的单个图形。下例向 myDocument 中添加三个三角形,然后将他们分组,设置整个组的颜色,最后再单独改变第二个三角形的颜色。

Set myDocument = Worksheets(1)
With myDocument.Shapes
    .AddShape(msoShapeIsoscelesTriangle, _
        10, 10, 100, 100).Name = "shpOne"
    .AddShape(msoShapeIsoscelesTriangle, _
        150, 10, 100, 100).Name = "shpTwo"
    .AddShape(msoShapeIsoscelesTriangle, _
        300, 10, 100, 100).Name = "shpThree"
    With .Range(Array("shpOne", "shpTwo", "shpThree")).Group
        .Fill.PresetTextured msoTextureBlueTissuePaper
        .GroupItems(2).Fill.PresetTextured msoTextureGreenMarble
    End With
End With