Change text colour of specific words in Numbers cells with AppleScript?
Hi,
I'm trying to make an AppleScript that allows me to change the colour of specific words in cells in Numbers (not the entire cells). I've tried it in Pages, where words are easily found and changed, but in a Numbers cell it doesn't seem to work the same way.
In my present case it's always the last word in the sentence that I want to change.
on run {input, parameters}
set testVal to "newcard"
set testCol to 2 -- column B
set newColor to {0, 0, 0}
tell application "Numbers"
tell front document's active sheet
tell (first table whose selection range's class is range)
repeat with r in rows 1 thru -1 -- skip header row
if r's cell testCol's value contains testVal then
-- set r's background color to backgroundColor1
-- set r's cells's text color to textColor1
-- set text color of testVal to newColor
set text color of (r's cell's value as string)'s last word to newColor
else
-- do something else
end if
end repeat
end tell
end tell
end tell
end run
I left some commented code that I used to test that everything else works. I can change cell background colour and the color of the entire cell text, where the word resides – just not isolated words.
I get the error message: "Syntax error. Can’t set «class texC» of "newcard" to {0, 0, 0}."
What am I doing wrong? :)
Thanks in anticipation!
Palle
MacBook Air 13″