Saturday, October 13, 2007

How do I change all red text to blue?

If you have applied the same colour in a lot of places in a document and want to change them all at once, you can run the following AppleScripts.

First you want to know the code of the colour you have. Put the cursor in a coloured word and run this script in Applications > AppleScript > Script Editor.

tell application "Pages"
tell front document
set S to selection
tell body text
set C to color of character before S
display dialog (((item 1 of C) as text) & ", " & ((item 2 of C) as text) & ", " & ((item 3 of C) as text))
end tell
end tell
end tell

Then run the following AppleScript, after you have changed the example colours to the ones you found running the previous script:

tell application "Pages"
repeat with achar in characters of body text of front document
if color of achar = {53355, 23, 54} then
set color of achar to {23, 54, 53355}
end if
end repeat
end tell

No comments: