View Single Post
  #15   Report Post  
Posted to microsoft.public.word.newusers
Tony Jollans Tony Jollans is offline
external usenet poster
 
Posts: 1,308
Default Macro for highlighting

There are two (VBA) statements that you seem to be confusing or
misunderstanding:

1. Selection.Range.HighlightColorIndex = wdRed

This highlights the selection without affecting the toolbar button - and is
the one to use to avoid sendkeys.

2. Options.DefaultHighlightColorIndex = wdRed

This changes the toolbar button (which then allows the sendkeys to use it to
get the chosen colour) but does not affect the text.

--
Enjoy,
Tony

"Anthony Giorgianni" d
wrote in message ...
Thanks Tony

But without using Sendkey, I can't figure out how simply to turn on
highlighting without selecting anything first. Am I missing something?


--
Regards,
Anthony Giorgianni

The return address for this post is fictitious. Please reply by posting
back
to the newsgroup.

"Tony Jollans" My forename at my surname dot com wrote in message
...
Whilst that may work for you ...

* most people don't have F10 - or any key - assigned to highlighting
* Sendkeys is generally best avoided

If you use the explicit statement (Selection.Range.HighlightColorIndex =
wdRed) that Lene and I have both suggested you will find it works just as
well. The only difference (which you'll generally be unaware of) is that

it
will work when Sendkeys would have failed, and also that it will work for
other people as well.

--
Enjoy,
Tony

"Anthony Giorgianni" wrote in message
...
Thanks Tony.

I found the problem. On my old laptop, I must have assigned F5 to turn

on
hgihlighting. So when I transferred the macro to my new laptop with
"Sendkey" F5, it didn't trigger the highlighter but instead ran Find
and
replace, the assignment for f5 on that machine :O)

Now it works fine with:

Sub HighLight_Red()
Selection.Range.HighlightColorIndex = wdRed
SendKeys "(F10)"

With F10 now assigned to turn on highlighting.

End Sub

Thanks again to you and Lene.

Regards,
Anthony Giorgianni

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