Share via


Ungroup Method [Publisher 2003 VBA Language Reference]

Ungroups the specified group of shapes or any groups of shapes in the specified shape range. If the specified shape is a picture or OLE object, Microsoft Publisher will break it apart and convert it to an ungrouped set of shapes. (For example, an embedded Microsoft Excel spreadsheet is converted into lines and text boxes.) Returns the ungrouped shapes as a single ShapeRange object.

expression.Ungroup

expression Required. An expression that returns one of the objects in the Applies To list.

Remarks

Using this method on an inline shape or a shape that isn't a group, picture, or OLE object generates an error. Also, an error occurs if the picture is a bitmap, JPEG, GIF, or PNG (Portable Network Graphics) file.

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. Also, newly ungrouped shapes are added to the Shapes collection on the current page (or pages) or scratch area. As a result, they may shift from one collection to another.

Example

This example ungroups any grouped shapes on the first page of the active publication.

Dim shpLoop As Shape

For Each shpLoop In ActiveDocument.Pages(1).Shapes
    If shpLoop.Type = pbGroup Then _
        shpLoop.Ungroup
Next shpLoop

Applies to | Shape Object | ShapeRange Collection