OK, I'm trying to do a very simple thing but the way to do it is eluding me. I just want to fill a shape with a Pantone color using a macro. Just one color from the basic Pantone coated palette (not Pantone+ or anything). I can't figure out the way to correctly identify the palette and color in a way that CorelDraw will recognize. Any help will be greatly appreciated.
Ric
There may be a more elegant way to get there than this, but this might help you get going:
Sub demonstrate_specifying_Pantone_color() Dim palThis As Palette Dim lngIndexOfColor As Long Dim colThis As Color Const strPaletteName As String = "PANTONE® solid coated" Const strColorName As String = "PANTONE Hexachrome Cyan C" Set palThis = Application.PaletteManager.GetPalette(strPaletteName) lngIndexOfColor = palThis.FindColor(strColorName) Set colThis = palThis.Color(lngIndexOfColor) ActiveShape.Fill.ApplyUniformFill colThis End Sub
If I needed to do that very much, I would wrap things up in a function - with some error handling! - so that I could supply the palette name and color name, and have it return the color.
Hello,
First macro is recorded. Second macro iterate all active color palettes to see names and identifiers.Greetings!
Sub PANTONE_COLOR() ' Recorded 16.3.2023 ã. Dim OrigSelection As ShapeRange Set OrigSelection = ActiveSelectionRange OrigSelection.ApplyUniformFill CreateSpotColor("a4e9990e-f1cc-4fae-9d93-53dcedb4261a", 2, 100) ActiveSelection.Fill.PSScreen.SetProperties "Default", 45#, 60End Sub
Sub ADD_PANTONE_COLOR()'ActiveShape.Fill.ApplyUniformFill CreateSpotColorByName(MsgBox Application.Palettes.CountDim mpal As PaletteFor Each mpal In Application.PalettesMsgBox mpal.Name & " " & "Identifier = " & mpal.IdentifierNextEnd Sub
Thank you for these subs as well. Early on, in my struggles with this segment of my project, I was able to come up with the "Windows Registry-looking" ID for the Pantone palette. It looked something like "6e75244b-d853-4d2e-bea2-a5da3f195d08".
I went with that at the time and it worked alright for a day. But the next time I tried it, the ID number for the palette had changed, so the code no longer worked. Is that something to be expected - that the long ID string of a given palette will change on a regular basis?
I can't find the reply I posted earlier, so here is another.
Thank you, Eskimo, for this great snippet. Exactly what I needed to make my project work.