Share via


ShapeRange.Group Method

Publisher Developer Reference

Groups the shapes in the specified shape range. Returns the grouped shapes as a single Shape object.

Syntax

expression.Group

expression   A variable that represents a ShapeRange object.

Return Value
Shape

Remarks

The specified range must contain more than one shape, or an error occurs.

Because a group of shapes is treated as a single shape, grouping and ungrouping shapes changes the number of items in the Shapes collection and changes the index numbers of items that come after the affected items in the collection.

Example

This example adds two shapes to the first page of the active publication, groups the two new shapes, sets the fill for the group, rotates the group, and sends the group to the back of the drawing layer.

Visual Basic for Applications
  With ActiveDocument.Pages(1).Shapes
' Add two shapes to the page.
.AddShape(Type:=msoShapeCan, _
    Left:=50, Top:=10, Width:=100, Height:=200).Name = "shpOne"
.AddShape(Type:=msoShapeCube, _
    Left:=150, Top:=250, Width:=100, Height:=200).Name = "shpTwo"

' Group the shapes and change the formatting for the whole group.
With .Range(Index:=Array("shpOne", "shpTwo")).<strong class="bterm">Group</strong>
    .Fill.PresetTextured PresetTexture:=msoTextureBlueTissuePaper
    .Rotation = 45
    .ZOrder ZOrderCmd:=msoSendToBack
End With

End With

See Also