Ungroup Method

Microsoft Word Visual Basic

Ungroup Method

       

Ungroups any grouped shapes in the specified shape or range of shapes. Disassembles pictures and OLE objects within the specified shape or range of shapes. Returns the ungrouped shapes as a single ShapeRange object.

expression.Ungroup

expression   Required. An expression that returns a ShapeRange object.

Remarks

Because a group of shapes is treated as a single object, 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 ungroups any grouped shapes and disassembles any pictures or OLE objects on myDocument.

Set myDocument = ActiveDocument
For Each s In myDocument.Shapes
    s.Ungroup
Next

This example ungroups any grouped shapes on myDocument without disassembling pictures or OLE objects on the document.

Set myDocument = ActiveDocument
For Each s In myDocument.Shapes
    If s.Type = msoGroup Then s.Ungroup
Next