Grouping objects inside object

Hi, this might be a long shot but ... Is there a way to group objects that are inside another object? One client sent me one file with thousands of id plate files in it, each plate consist of a logo a  serial number and the box containing both but everything is ungrouped, so now I have to manually group each box and the data inside it one by one. Is there a way to do this with a macro or directly in Corel?

Parents Reply Children
  • Fair enough, I've sent you an email

    I have sent you a macro.

    This is identifying the tags based on the fact that they are the only shapes on the layer named, "Hueso". If you have documents where that is not the case, then the query could be modified to identify the tags in some different way (e.g., type of shape, size, outline color).

    It is not checking to see if shapes are "completely within" the boundary of the tag. It is finding the shapes that are within the smallest rectangle that would contain the tag. In this case, I think that is good enough.

    Sub group_to_tags()
    Dim sr_tags As ShapeRange
    Dim sThisTag As Shape
    Dim srTemp As ShapeRange
    Dim dblLeftX As Double
    Dim dblRightX As Double
    Dim dblBottomY As Double
    Dim dblTopY As Double
    
    
        On Error GoTo ErrHandler
        Optimization = True
        EventsEnabled = False
        ActiveDocument.BeginCommandGroup "Group to tags"
        
        Set sr_tags = ActivePage.Shapes.FindShapes(, , False, "@com.layer.name = 'Hueso'")
        
        For Each sThisTag In sr_tags
            dblLeftX = sThisTag.LeftX
            dblRightX = sThisTag.RightX
            dblBottomY = sThisTag.BottomY
            dblTopY = sThisTag.TopY
            
            Set srTemp = ActivePage.Shapes.FindShapes(, , False, "@com.leftx > " & dblLeftX & " and @com.rightx < " & dblRightX & " and @com.BottomY > " & dblBottomY & " and @com.TopY < " & dblTopY)
            srTemp.Add sThisTag
            srTemp.Group
        Next sThisTag
        
        MsgBox "Done."
        
    ExitSub:
        ActiveDocument.EndCommandGroup
        EventsEnabled = True
        Optimization = False
        Refresh
        
        Exit Sub
    
    ErrHandler:
        MsgBox "Error occured: " & Err.Description
        Resume ExitSub
    End Sub