Delete all shading

R

rhamre

Alright, now... i only ask questions when i really need help... so here goes.

I have documents that have all this highlighting to help notify people of
issues that may or may not be problematic, so i have this-

Sub RemoveHighlights()

Dim rngSearch As Word.Range

Application.ScreenUpdating = False

Set rngSearch = ActiveDocument.Range

rngSearch.Find.ClearFormatting
rngSearch.Find.Replacement.ClearFormatting

With rngSearch.Find
.Format = True
.highLight = True
.Replacement.highLight = False
.Execute Replace:=wdReplaceAll
End With

Application.ScreenUpdating = True

End Sub

Well, i get a document, and it turns out a programmer has added shading, not
highlighting.

I've tried all kinds of things to delete shading using a range, and i can't
figure it out. I searched through past threads and didn't find anything also.

If anyone could help it'd be much appreciated.

Thanks guys.
 
D

Dave Lett

Hi,

I think you can use something like the following:

With ActiveDocument.Range
.HighlightColorIndex = wdNoHighlight
.Shading.BackgroundPatternColorIndex = wdNoHighlight
End With

HTH,
Dave
 
C

Chuck Henrich

If you want to remove *all* shading and highlighting, you could use the
following instead of find/replace:

With ActiveDocument.Range
With .Font.Shading
.Texture = wdTextureNone
.ForegroundPatternColor = wdColorAutomatic
.BackgroundPatternColor = wdColorAutomatic
End With
.HighlightColorIndex = wdNoHighlight
End With

Alternatively you could loop through all the paragraphs (or even words) in
your document looking for a particular shading background color or background
color index and replacing it with 0 (for wdColorAutomatic), eg:

Dim p As Paragraph

For Each p In ActiveDocument.Paragraphs
'XX = index number or constant for the shading
'you want to remove
If p.Range.Font.Shading.BackgroundPatternColorIndex = XX Then
p.Range.Font.Shading.BackgroundPatternColorIndex = 0
End If
Next p

You can also set your criteria to background color, foreground color/color
index, texture, etc.

HTH
 

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