Hi. I have been using X7 for years, utilising a macro found on this forum to label my colors in a spec sheet for my artwork.
We have recently decided to upgrade to 2021.
The color label macro no longer recognises color names from my custom color palettes. It produces "unnamed color" instead.
If I run the macro on a color from a default palette such as Pantone+ Uncoated, as an example, the macro does recognises the color name.
If I run the stock ColorChartCreator macro on my custom palette, it does recognise the color names.
I am not sure with the 2021 update whether there is a compatibility issue with the col.name label in the macro, the macro itself or the color palette.
I have included the code below. If anyone has experienced and solved I would greatly appreciate it.
Sub LabelSwatches() Dim sr As ShapeRange, sh As Shape, cn As Shape, col As Color ActiveDocument.Unit = cdrInch Set sr = ActiveSelectionRange If sr.Count = 0 Then MsgBox "Nothing selected!": Exit Sub ActiveDocument.BeginCommandGroup "ColorsNames" For Each sh In sr Set col = sh.Fill.UniformColor Set cn = ActiveDocument.ActiveLayer.CreateArtisticText(sh.CenterX, sh.CenterY + (sh.SizeHeight / 2.5), col.Name & vbCr & col.Name(True), cdrEnglishUS, , "Arial", sh.SizeWidth / 0.18, , , , cdrCenterAlignment) cn.Fill.ApplyUniformFill CreateCMYKColor(0, 0, 0, 0) Next sh ActiveDocument.EndCommandGroupEnd Sub
Eskimo,
Thank you for the tips. Indeed you can get the palette from the color. So here is an improved version that does not require the palette to be open.
Sub LabelSwatches() Dim sr As ShapeRange, sh As Shape, cn As Shape, col As Color, pal As Palette ActiveDocument.Unit = cdrInch Set sr = ActiveSelectionRange If sr.Count = 0 Then MsgBox "Nothing selected!": Exit Sub ActiveDocument.BeginCommandGroup "ColorsNames" For Each sh In sr Set col = sh.Fill.UniformColor Set pal = col.Palette Set cn = ActiveDocument.ActiveLayer.CreateArtisticText(sh.CenterX, sh.CenterY + (sh.SizeHeight / 2.5), pal.Color(pal.GetIndexOfColor(col)).Name & vbCr & col.Name(True), cdrEnglishUS, , "Arial", sh.SizeWidth / 0.18, , , , cdrCenterAlignment) cn.Fill.ApplyUniformFill CreateCMYKColor(0, 0, 0, 0) Next sh ActiveDocument.EndCommandGroup End Sub
Thanks again,
-Shelby
This is great, thank you team.