View Single Post
  #20   Report Post  
Posted to microsoft.public.word.newusers
Anthony Giorgianni Anthony Giorgianni is offline
external usenet poster
 
Posts: 4
Default Macro for highlighting

Thanks everyone for your help.

I think I'll simply to stick with using the sendkeys command. That's a neat
macro Lene but doesn't seem to do what I'm looking for. I think I'm probably
not explaining it right. All I want to be able to do is simply turn on
highlighting with a certain color with one click, avoiding having to go up
to the highlighting menu item, select the color and turn it on.

The reason is that, as a journalist, many times I'm reading a document and
want to highlight items for different importance - green = interesting but
not critical, yellow = pretty important, red = information that I must use.
So when I see something pretty important, I want to turn on yellow
highlighting with one click of a toolbar icon. Then I highlight that
(usually without selecting it first) Later I might see something that's
critical, so I want to turn on red highlighting with one click.

This does that exactly

Options.DefaultHighlightColorIndex = wdYellow REM: Selects the
highlighting color yellow
SendKeys "{F5}" REM Turns on highlighting, where Word has been set to
associate F5 with turning on highlighting.

Tony suggested that using sendkeys isn't the best way to do this. It
certainly doesn't make the macro portable if I want to transfer it to
another machine without having to set F5 (as I found out when I tried to
transfer it from my home to my work machine and forgot about setting F5 to
turn on highlighting.) So I was curious if there was another way to do it.
But it's no big deal. It works fine. By the way, to make it really easy, I
created a "highlighting" toolbar with icons that are simply colored squares,
each assigned to a different color macro and one assigned to "no color" for
clearing.

Thanks again.

Regards
Anthony Giorgianni

For everyone's benefit, please reply to the group.




"Lene Fredborg" wrote in message
...
Greg,

About changing the previous highlighting too: after reading the

description
again now, I am sure you are right - however, I did not read it that way
first.

About the insertion point being in a word: you are right, if the option
"When selecting, automatically select entire word" in Tools Options

Edit
tab is turned on, the code line "Selection.Range.HighlightColorIndex =

wdRed"
would highlight that word. I should have taken this into consideration by
making a check in the code as you did in your version - unfortunately, I
failed to notice this because I do not have that option turned on.

--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word