Dim shapeGroup As New WorksheetShapeGroup()
shapeGroup.Shapes.Add(shape1)
shapeGroup.Shapes.Add(shape2)
This topic demonstrates how to group two or more shapes.
You need to first read the following topics:
A group of shapes is a structure consisting of two or more that behave like one shape. Working with groups of shapes is similar to working with Worksheet Class and WorksheetShape Class.
To group two or more shapes ensure you have the shapes initialized, then initialize a WorksheetShapeGroup object and add the shapes to its Shapes collection.
The procedure that follows demonstrates how to group two already initialized shapes.
To complete the procedure, you need the following:
Initialize two WorksheetShape objects
Add the result of this procedure to a Worksheet
Following is a conceptual overview of the process:
Initialize two shapes
Group the shapes
Set position and size. Add to a worksheet.
Initialize two shapes
Name the objects shape1 and shape2. To complete this step refer to the Adding a Shape to a Worksheet topic.
Group the shapes
Initialize a new WorksheetShapeGroup object and add the shapes to its Shapes collection.
In Visual Basic:
Dim shapeGroup As New WorksheetShapeGroup()
shapeGroup.Shapes.Add(shape1)
shapeGroup.Shapes.Add(shape2)
In C#:
WorksheetShapeGroup shapeGroup = new WorksheetShapeGroup();
shapeGroup.Shapes.Add(shape1);
shapeGroup.Shapes.Add(shape2);
Set position and size. Add to a worksheet.
WorksheetShapeGroup Class derives from WorksheetShape Class, so everything about sizing, positioning, adding to a sheet and etc is the same as Adding a Shape to a Worksheet.
Following are some other topics you may find useful.