How find and replace specific colour highlights?


G

Guest

How do I do a macro that finds all highlights in a praticular colour in a
document and replaces them with highlights of a different colur, or with no
highlight at all?
 
Ad

Advertisements

H

Helmut Weber

Hi, just one of some ways:
Sub Test453()
Dim oRng As Range
Set oRng = ActiveDocument.Range
ResetSearch
With oRng.Find
.Text = ""
.Highlight = True
While .Execute
If oRng.HighlightColorIndex = wdYellow Then
oRng.HighlightColorIndex = wdAuto
End If
oRng.Start = oRng.End
oRng.End = ActiveDocument.Range.End
Wend
End With
ResetSearch
End Sub
'---
Private Sub ResetSearch()
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute
End With
End Sub
 

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