Group Shapes
Sometimes you’ll want to perform the same operation on more than one shape. The easiest way to do that is to group the shapes using the ShapeRange object, then perform the operation on that object. The following code demonstrates how to group objects as a ShareRange:
Sub GroupObjects( )
Dim ws As Worksheet, s As Shape, sr As ShapeRange
Set ws = ActiveSheet
' Create a ShapeRange containing the last two shapes drawn.
Set sr = ws.Shapes.Range(Array(ws.Shapes.Count - 1, ws.Shapes.Count))
' Flip the objects
sr.Flip msoFlipHorizontal
' Group the objects in the Excel UI.
sr.Group
End SubThe ShapeRange object’s Group method groups the objects so they can be moved, resized, or deleted as a unit by the user. If you run GroupObjects after InsertWordArt, both the wombat and the text are flipped, as shown in Figure 18-10.

Figure 18-10. Grouping objects with ShapeRange
The ShareRange object has almost all of the same members as the Shape object, and as with Shape, some of those members aren’t valid for certain types of shapes.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access