I am trying to write a script that looks at all of the text boxes on my page, and changes the fill color of the text based on what the original color was. I can get the script to work on the fill color of the text box itself and I can also get it to work on a single character, but not all the characters in the box. I would appreciate any pointers.
I am posting the 2 scripts that are working to show you how far I’ve gotten. Thanks so much for all your help!
tell application "Adobe InDesign CS2"
tell active document
set myBlackSwatch to swatch "Black"
set redswatch to swatch "red"
set blueswatch to swatch "blue"
set TextBoxCount to the count of every text frame
--this works, changing the background fill of all the text boxes.
repeat with i from 1 to TextBoxCount
tell text frame i
if fill color is myBlackSwatch then
set fill color to redswatch
else
set fill color to blueswatch
end if
end tell
end repeat
end tell
end tell
tell application "Adobe InDesign CS2"
tell active document
set myBlackSwatch to swatch "Black"
set redswatch to swatch "red"
set blueswatch to swatch "blue"
set TextBoxCount to the count of every text frame
repeat with i from 1 to TextBoxCount
tell text frame i
--alt this works to change the color of letter 1, but i can't make select every character work
select character 1
if fill color of character 1 is myBlackSwatch then
set fill color of character 1 to redswatch
else
set fill color of character 1 to blueswatch
end if
end tell
end repeat
end tell
end tell