View Single Post
  #8  
Old 03-02-2009, 16:53
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Or try this code:

Code:
Public Sub ExtractSelectedFromGroup()
    Dim sObj As Shape
    Dim sGroup As Shape
    
    Set sObj = ActiveShape
    If sObj Is Nothing Then
        MsgBox "Nothing selected", vbCritical
        Exit Sub
    End If
    
    Set sGroup = sObj.ParentGroup
    If sGroup Is Nothing Then
        MsgBox "Selected object is not part of a group", vbCritical
        Exit Sub
    End If
    
    If sGroup.Shapes.Count < 3 Then
        ' Only two (or less) objects in a group.
        ' Should just ungroup everything
        sGroup.Ungroup
    Else
        ' Extract the object and put in in front of the group
        sObj.OrderFrontOf sGroup
    End If
    
    sObj.CreateSelection
End Sub
Reply With Quote