AppleScript(s) to change font colors?

B

boboq

Version: 2008
Operating System: Mac OS X 10.5 (Leopard)
Processor: Intel

Hi:

In Word (and PowerPoint) X and 2004, I had macros that allowed me to select text and change its color via a predefined key combination. This allowed me to quickly highlight text in various colors. This feature is gone in 2008, and apparently you can use AppleScript to replace this function.

I have tried to search various web sites for some ideas for how to write such a script and have tried to play with modifying some existing scripts so that they would, for example, change font color rather than pasting unformatted text. However, I am not having any luck.

I'd really appreciate it if an AppleScript savvy colleague could 1) point me to a site where such scripts exist; or 2) give me some examples of appropriate scripting language to write such scripts.

Thanks in advance.

Bob Q.
 
D

Daiya Mitchell

Finally! Applescript question I can answer! Except, after I looked up
the script I discovered you can use Automator instead. Foiled again!

Option 1:

Avoid scripts entirely and use a Character Style that applies color.
This is probably most useful for text with some sort of structural
consistency that you might want to track--say, you are tagging all your
Quotations green as you type to see how much text is directly quoted and
then later you want to remove that green you can just redefine the
character styles to no color, but leave the style applied. Or, let's say
you are taking notes from a book and color coding different topics--I
think a Character style might let you Select All Green Character Style
text and copy it to a new doc at once, via Find and Replace.

But character styles can get confusing as they overlap with other styles
or formatting, so you are fine to avoid them. And you might be able to
do Copy All Green Text without character styles, not quite sure. If you
haven't run into these needs before, you probably won't.

Option 2:

this works on my machine:

tell application "Microsoft Word"
set color index of font object of selection to green
activate
--I'm not totally sure the activate is necessary, but I think it's
useful to make sure focus is returned
end tell

Installation Instructions:
http://word.mvps.org/mac/InstallApplescript.html

The Word 2004 AppleScript Reference (page 114-115) says your options
(instead of green) are:

auto
black
blue
bright
green
dark blue
dark red
dark yellow
gray25
gray50
green
no highlight
pink
red
teal
turquoise
violet
white
yellow

There's a mysterious line about a different way to specify RGB colors
that I didn't manage to make work.

Option 3:

Automator--UNLESS you have the home and student version, there is a
pre-built Action for Word in Automator, "Apply Font Format Settings"
that would let you apply a color to selected text, and you can select
from the entire OS X color wheel, looks like. I didn't test this one.

Daiya
 
B

boboq

Perfect! Thanks so much! (And thanks for the prompt reply.)

Now I just have to figure out how to assign keyboard shortcuts. ;-)>

BQ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top