ShapeRange.Group method (Publisher)
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.
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")).Group
.Fill.PresetTextured PresetTexture:=msoTextureBlueTissuePaper
.Rotation = 45
.ZOrder ZOrderCmd:=msoSendToBack
End With
End With
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.