Ungroup Method

Microsoft Publisher Visual Basic

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