Working with font in range = ActiveDoc.Content?

E

Ed

In one of my macros, changes made are identified by changing the font color
or highlighting the text that was changed. I tried to do a clean-up by
setting a range to ActiveDocument.Content, and resetting the font color and
highlighting that way, but it didn't work. I would appreciate it if someone
could tell me what's wrong with this.

Ed

Set rngWork = ActiveDocument.Content
With rngWork.Font
.Color = wdColorAutomatic
.HighlightColorIndex = wdNoHighlight
End With
 
J

Jean-Guy Marcil

Hi Ed,

Try this instead:

'_______________________________________
Set rngWork = ActiveDocument.Content

With rngWork
.Font.Color = wdColorAutomatic
.HighlightColorIndex = wdNoHighlight
End With
'_______________________________________

HighlightColorIndex is a range property, you were trying to apply it to a
Font object.
Unless there was something else that did not work?

Please, when writing about a problem, e.g.
setting a range to ActiveDocument.Content, and resetting the font color and
highlighting that way, but it didn't work. I would appreciate it if
someone

Try to avoid writing "It didn't work." Write exactly "What" did not work, or
"How" it did not work or How the results obtained were not satisfactory...
This was a simple thing, but it is a good habit to get into... So if you
write about something more complicated readers won't be at loss trying to
figure out what is wrong! Especially if it is a case that The poster expects
results that are not realistic with the code used (when in fact the code
used yields exactly what it is supposed to yields!) This is not the case
here, but I am just pointing out a little thing pet peeve, please do not
take it personally, I am hoping that other readers will also benefit from
this little rant of mine!

Thanks!
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
E

Ed

Thank you.
Set rngWork = ActiveDocument.Content

With rngWork
.Font.Color = wdColorAutomatic
.HighlightColorIndex = wdNoHighlight
End With

HighlightColorIndex is a range property, you were trying to apply it to a
Font object.

Okay - that's easy enough to understand. Hard to remember all of this, but
I'm getting lots of practice rewriting my code!! 8>)
Try to avoid writing "It didn't work." Write exactly "What" did not work, or
"How" it did not work or How the results obtained were not satisfactory...
This was a simple thing, but it is a good habit to get into...

You're right - I should have written that the font color did not change to
Automatic and the hgihlighting did not go away. Yes, in *this* case, it was
probably easy to infer the "what didn't work", but that's making the people
who are nice enough to help me work harder than they should have to.

Thanks again for the assist.

Ed
 

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