Sort Outline colours, fill etc.

Hallo,

I often have plans where all shapes on the same Layer.

It is not very funny to sort this

Until now I work with function "search and find", make groups an layers.

So the idea was to write a Macro.

 For this project I have found different Macros, they are working good:

Sub ungroup()
    ActivePage.Shapes.All.CreateSelection
    Dim s1 As Shape
    Set s1 = ActiveSelection.Group
    Dim grp1 As ShapeRange
    Set grp1 = s1.UngroupAllEx
    ActiveDocument.ClearSelection
End Sub 

Sub findBitmaps()
Set sr = ActivePage.Shapes.FindShapes(Type:=cdrBitmapShape)
sr.delete
End Sub

Sub Fill()
Dim lr1 As Layer
Dim s As Shape
For Each s In ActivePage.Shapes
If s.Fill.Type = cdrUniformFill Then
s.AddToSelection
End If
Next s
ActiveSelection.Group.Cut
Set lr1 = ActivePage.CreateLayer("Fill")
CorelScript.PasteFromClipboard
End Sub

Sub Outline()
Dim lr1 As Layer
Set lr1 = ActivePage.CreateLayer("255_0_0")
Set sr = ActivePage.Shapes.FindShapes(Query:="@outline.color = RGB(255, 0, 0)")
sr.Group
End Sub

Furthermore I have found the manual function to take colours from a document into a new palette.

Now I have two problems:

- How could I search outline for every Colour which is used in the document (different in every document) ?

- How could I put the parts together, that the macro still work

Thank you for help

  • The following will look at your Current Selection and Move each Outline Color to its own layer.

    Sub OutlinesToLayers()
        Dim srSelection As ShapeRange, srOutlines As ShapeRange, srFound As ShapeRange
        Dim c As Color
        Dim s As Shape
        Dim l As Layer
        
        Set srSelection = ActiveSelectionRange
        Set srOutlines = srSelection.Shapes.FindShapes(Query:="@outline.type <> 'none'")
        
        Do
            Set s = srOutlines.FirstShape
            Set c = s.Outline.Color
            c.ConvertToRGB
            
            Set l = ActivePage.CreateLayer(c.RGBRed & "_" & c.RGBGreen & "_" & c.RGBBlue)
            
            Set srFound = srOutlines.Shapes.FindShapes(Query:="@outline.color = '" & c.ToString & "'")
            srFound.Group
            srFound.MoveToLayer l
            
            srOutlines.RemoveRange srFound
        Loop Until srOutlines.Shapes.Count = 0
    End Sub
    

    Hope that helps,

    -Shelby