View Single Post
 
Old 11-03-2013, 03:42 PM
bertietheblue bertietheblue is offline Windows 7 64bit Office 2003
Advanced Beginner
 
Join Date: May 2012
Location: United Kingdom
Posts: 54
bertietheblue is on a distinguished road
Default Macro to highlight 100s of proper nouns

Hi

I received a lot of help on here before from Big0, who came up with a macro (below) to highlight a list of proper nouns and phrases. It works fine but I just need to make a couple of tweaks:

- I can only put a limited number of terms in the find text array - I need many 100s (I've just left 'England' in the below for ease of reading; I can add about 60-70 terms without being unable to add more)
- I need to put some phrases with brackets in them into the array, but it doesn't allow this at present.

Any help adapting slightly would be appreciated.

Thanks
Bertie
Code:
Sub ReplaceList()
Dim vFindText As Variant
Dim vReplText As Variant
Dim i As Long
'highlight red words
Options.DefaultHighlightColorIndex = wdRed
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
vFindText = Array("England")
vReplText = "^&"
With Selection.Find
  .Forward = True
  .Wrap = wdFindContinue
  .MatchWholeWord = True
  .MatchWildcards = False
  .MatchSoundsLike = False
  .MatchAllWordForms = False
  .Format = True
  .MatchCase = True
  For i = LBound(vFindText) To UBound(vFindText)
    .Text = vFindText(i)
    .Replacement.Text = vReplText
    .Replacement.Highlight = True
    .Execute Replace:=wdReplaceAll
  Next i
End With
End Sub

Last edited by macropod; 11-03-2013 at 03:48 PM. Reason: Added code tags & formatting
Reply With Quote