Automatic color change in long document.

  • Thread starter Special Agent Melvin Purvis
  • Start date
S

Special Agent Melvin Purvis

I have a large document, some 32 chapters. I would like to color-code
certain words wherever they appear. Doing this manually is extremely
tedious. Is it possible to do this with the find and replace
function?

Thanks in advance for the help.
 
G

Graham Mayor

You can certainly highlight or colour words using the replace function.
Check the More box for additional options

Put the word you want to find in the Find box
Click in the Replace box and then format > Highlight or Font > Colour

or if there is more than one word to check use a macro. Put the words to
want to check in the Array - in quotes and separated by commas e.g.
("lorem", "ipsum", "dolor") http://www.gmayor.com/installing_macro.htm



Sub ReplaceList()
Dim vFindText
Dim r As Range
Dim i As Long
vFindText = Array("lorem", "ipsum", "dolor") 'Put your words in this array
For i = 0 To UBound(vFindText)
Set r = ActiveDocument.Range
With r.Find
.Text = vFindText(i)
Do While .Execute(Forward:=True, MatchWholeWord:=True) = True
r.HighlightColorIndex = wdYellow
Loop
End With
Next
End Sub

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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