Table of contents
TOC
Collapse the table of content
Expand the table of content

ShapeRange.Group Method (Publisher)

office 365 dev account|Last Updated: 8/24/2017
|
3 Contributors

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 
© 2018 Microsoft