April 2006
Beginner
1114 pages
98h 16m
English
shaperange.Group( )
Groups the shapes in the ShapeRange so that they can be selected, moved, or deleted as a single shape by the user. The following code demonstrates grouping and ungrouping the shapes on a worksheet:
Sub GroupUngroup( )
Dim ws As Worksheet, sr As ShapeRange, s As Shape
Set ws = ActiveSheet
Select Case ws.Shapes.Count
Case Is > 1
' Create a shape range for all shapes on sheet.
ws.Shapes.SelectAll
Set sr = Selection.ShapeRange
' Group all the items
Set s = sr.Group
' Show count of items in group.
Debug.Print s.GroupItems.Count & " shapes grouped."
Case 1
ws.Shapes(1).Ungroup
Debug.Print "Ungrouped shapes"
Case 0
Debug.Print "No shapes to group."
End Select
End SubRead now
Unlock full access