Share via


Group Method [Visio 2003 SDK Documentation]

Groups the objects that are selected in a selection, or it converts a shape into a group.

shpObj = object**.Group**

shpObj     Object. The resulting Shape object.

object     Required. An expression that returns a Shape or Selection object.

Version added

2.0

Example

The following example shows how to group Shape objects.

Public Sub Group_Example() 

    Dim vsoShape1 As Visio.Shape 
    Dim vsoShape2 As Visio.Shape 
    Dim vsoGroupShape As Visio.Shape 
    Dim vsoSelection As Visio.Selection 

    'Draw two rectangles. 
    Set vsoShape1 = ActivePage.DrawRectangle(1, 2, 2, 1) 
    Set vsoShape2 = ActivePage.DrawRectangle(1, 4, 2, 3) 

    'Deselect all shapes, and then select the two rectangles. 
    Set vsoSelection = ActiveWindow.Selection 
    vsoSelection.Select vsoShape1, visDeselectAll + visSelect 
    vsoSelection.Select vsoShape2, visSelect 

    'Group the rectangles into a group shape. 
    Set vsoGroupShape = vsoSelection.Group 

End Sub  

Applies to | Selection object | Shape object

See Also | AddToGroup method | ConvertToGroup method | RemoveFromGroup method | Ungroup method