I'm trying to take a list of Color Codes and spit out a chart with the colors actually visible.
I'm trying the script* in this post from the Apple Support Forums:
The script worked once on a sample.. but then not again (and it didn't work quite like I expected)
This is what my table (sample) looks like**:
When I ran it and it worked, once, it gave me this
Why the first cell that has no "#" which should be the trigger according to the script colored as well, I don't know...but as I said, it didn't work a second time
Can anyone help me figure this all out?
*This is the script, by Apple Forum user SGIII , I'm trying reposted for convience:
**(I changed my table to match the look in the original post to simplify my understanding of the code.....this is the actual table:
I'm trying the script* in this post from the Apple Support Forums:
Change cell background color based on the… - Apple Community
discussions.apple.com
The script worked once on a sample.. but then not again (and it didn't work quite like I expected)
This is what my table (sample) looks like**:
When I ran it and it worked, once, it gave me this
Why the first cell that has no "#" which should be the trigger according to the script colored as well, I don't know...but as I said, it didn't work a second time
Can anyone help me figure this all out?
*This is the script, by Apple Forum user SGIII , I'm trying reposted for convience:
AppleScript:
property hexChrs : "0123456789abcdef"
tell application "Numbers"
tell front document
tell active sheet
tell (first table whose class of selection range is range)
set outList to {}
repeat with aCell in cells of (get selection range)
set v to value of aCell
if text 1 of v is "#" then set v to text 2 thru -1 of v
set hexColor to my hexColorToRGB(v)
set inverseColor to {}
repeat with i from 1 to 3
copy (65535 - (item i of hexColor)) to end of inverseColor
end repeat
if v is "808080" then set inverseColor to {65535, 65535, 65535} -- hack to adjust gray
set background color of aCell to hexColor
set text color of aCell to inverseColor
end repeat
end tell
end tell
end tell
end tell
return outList
on hexColorToRGB(h) -- convert
if (count h) < 6 then my badColor(h)
set rgbColor to {}
try
repeat with i from 1 to 6 by 2
set end of rgbColor to ((my getHexVal(text i of h)) * 16 + (my getHexVal(text (i + 1) of h))) * 257
end repeat
end try
if (count rgbColor) < 3 then my badColor(h)
return rgbColor
end hexColorToRGB
on getHexVal(c)
if c is not in hexChrs then error
set text item delimiters to c
return (count text item 1 of hexChrs)
end getHexVal
on badColor(n)
display alert n & " is not a valid hex color" buttons {"OK"} cancel button "OK"
end badColor
**(I changed my table to match the look in the original post to simplify my understanding of the code.....this is the actual table: