View Single Post
Old 30-03-2004, 09:03
Alex's Avatar
Alex Alex is offline
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default Re: Finding Color Currently Selected in RGB or CMYK Palette

Well, I'm not sure I understand your problem. As far as I know, there is no "selected color" in a palette. When you click on a color well in a palette, the color gets applied to the selected object(s) fills/outlines but the palette itself loses the color selection the same instant. It doesn't know and it doesn't care which one you selected.

If you want to inspect the fill color of selected object, then you can do it like this:

to return the value of red component of RGB color. Of course, you need to test first if the object has the uniform color first. If this is the case, then you need to see the color model. Finally, if it's RGB, you can access all those RGBRed, RGBGreen, RGBBlue properties.

You can create a copy of the color object and convert the color to the specific color model if you want to get RGB equivalent of the current fill color:

Sub InspectColors()
    Dim c As New Color
    If ActiveShape Is Nothing Then
        MsgBox "No object selected", vbCritical
        Exit Sub
    End If
    If ActiveShape.Fill.Type <> cdrUniformFill Then
        MsgBox "The selected object doesn't have a uniform fill", vbCritical
        Exit Sub
    End If
    c.CopyAssign ActiveShape.Fill.UniformColor
    MsgBox "The fill color RGB equivalent is: RGB(" & c.RGBRed & "," & c.RGBGreen & "," & c.RGBBlue & ")"
End Sub
Obviously, you can do a lot more with colors, and they don't have to be in object's fill/outline. But I don't know what exactly you are trying to do, so I'll let you figure out the rest

If you want some more examples, you might want to take a look at Color replacer macro ( Or look in the VBA help file on Color object, or read the CorelDRAW VBA programming guide manual (dvba_pg.pdf in Programs folder of your CorelDRAW installation). This should give you more info.
Reply With Quote