Color Name not recognised in Color Label Macro in 2021

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.EndCommandGroup
End Sub

Parents
No Data
Reply
  • Mr. Moosen, 

    Here is the workaround I came up with. You will need to have the palette open that you used to fill the shapes, I then match the color to the palette and get the name of the color from the palette.

    Sub LabelSwatches()
        Dim sr As ShapeRange, sh As Shape, cn As Shape, col As Color, pal As Palette, i As Integer
    
        ActiveDocument.Unit = cdrInch
    
        Set sr = ActiveSelectionRange
        Set pal = ActivePalette
    
        If sr.Count = 0 Then MsgBox "Nothing selected!": Exit Sub
    
        ActiveDocument.BeginCommandGroup "ColorsNames"
            For Each sh In sr
                Set col = sh.Fill.UniformColor
                i = pal.MatchColor(col)
                Set cn = ActiveDocument.ActiveLayer.CreateArtisticText(sh.CenterX, sh.CenterY + (sh.SizeHeight / 2.5), pal.Color(i).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
    

    Hopefully that helps,

    -Shelby

Children