Replace shading with highlights

G

Guest

Is it possible to find and replace format/shading with the same color from
highlights? Do you have any tips for doing this through a large document
that has 2 colors in format/shading that need to be replaced with highlights?
Thank you.
 
J

Jay Freedman

Mickey said:
Is it possible to find and replace format/shading with the same color
from highlights? Do you have any tips for doing this through a large
document that has 2 colors in format/shading that need to be replaced
with highlights? Thank you.

Hi Mickey,

It's possible, using a macro, if a couple of assumptions are true:

- The exact color of the shading is known. For example, that it's yellow and
not some custom color that looks yellow.

- The shaded text consists of whole words (or, preferably, larger pieces
such as whole paragraphs). It's possible to look for shading applied to
individual characters or parts of words, but in a large document you'd grow
old waiting for it to finish. Checking words is a reasonable compromise,
maybe.

If that fits the bill, you can use a macro like this (see
http://www.gmayor.com/installing_macro.htm if needed). Change the color
designations in the macro as necessary to match the document colors.

Sub ShadeToHilite()
' change red shading to red highlighting
' change yellow shading to yellow highlighting
' ignore all other colors

Dim oWd As Range
For Each oWd In ActiveDocument.Words
With oWd
If .Shading.BackgroundPatternColorIndex _
= wdRed Then
.Shading.BackgroundPatternColorIndex _
= wdAuto
.HighlightColorIndex = wdRed
ElseIf .Shading.BackgroundPatternColorIndex _
= wdYellow Then
.Shading.BackgroundPatternColorIndex _
= wdAuto
.HighlightColorIndex = wdYellow
End If
End With
Next
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

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