Hi there,
I have a document with lot of different shapes and I want to group all of them with same FillColor.
I'm having troubles getting the list (palette) of colors are being used in ActiveDocument.
In CD 20020 exists the method ShapeRange.GetColors but unfortunately I'm working on X8.
Any clue?
Important: Amount of shapes is amazing (Autocad exported pdf) so looping them is almost unuseful.
Thanks in advence,
Anderl
find a copy of the Select Same macro that will work with your version of CorelDRAW. That's what it does.
Hi Roy, thanks for your time.SelectSame doesn't do the same because there is an input color (color of initially selected shape).In my case, I have lot shapes of unknown colors, from which I want to get a "list" (array or similar). Then I will try to use each entry in that list to locate all the matches using the FindShapes method.That is my plan, but I cannot determine what colors are initially in the document, and that is what I need your help for.
This code should work in all versions:
Sub Test_01()Dim SR1 As ShapeRange, SR2 As ShapeRange, CurSh As ShapeDim ColArr(32) As String, CurCol As Integer, ColPos As Integer, ColCnt As IntegerSet SR1 = ActivePage.Shapes.AllColCnt = 0For Each CurSh In SR1.Shapes If CurSh.Type = cdrEllipseShape Then ColPos = 0 For CurCol = 1 To ColCnt If ColArr(CurCol) = CurSh.Fill.UniformColor.HexValue Then ColPos = CurCol Next CurCol If ColPos = 0 Then ColCnt = ColCnt + 1 ColArr(ColCnt) = CurSh.Fill.UniformColor.HexValue End If End IfNext CurShFor CurCol = 1 To ColCnt Set SR2 = New ShapeRange For Each CurSh In SR1.Shapes If CurSh.Fill.UniformColor.HexValue = ColArr(CurCol) Then SR2.Add CurSh Next CurSh Set CurSh = SR2.Group CurSh.Name = ColArr(CurCol)Next CurCol'MsgBox ColCntEnd Sub
Have you looked at the "Color Click Extreme" macro from GDG Macros?
That is really made for (1) showing you which colors are present and (2) selecting objects based on color.
Hello NudeFan,
Unfortunately, as I said at the beginning, the document contains thousands shapes (and I have hundreds of documents) so I want to avoid a solution involving a loop through all shapes.