![]() |
#30
|
||||
|
||||
![]()
By changing:
.MatchAllWordForms = True to: .MatchAllWordForms = False the code already works for any punctuation except a comma. If you need to work with commas as well, use: Code:
Sub HiLightList() Application.ScreenUpdating = False Dim StrFnd As String, h As Long, i As Long h = Options.DefaultHighlightColorIndex Options.DefaultHighlightColorIndex = wdYellow StrFnd = "dog|cat|pig|horse|man" With ActiveDocument.Range.Find .ClearFormatting .Replacement.ClearFormatting .Replacement.Highlight = True .Forward = True .Wrap = wdFindContinue .Format = True .Font.Underline = False .MatchCase = True .MatchWholeWord = True .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False .Replacement.Text = "^&" For i = 0 To UBound(Split(StrFnd, "|")) .Text = Split(StrFnd, "|")(i) .Execute Replace:=wdReplaceAll Next End With Options.DefaultHighlightColorIndex = h Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Tags |
find, highlight, multiple keywords |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
APAV | Word | 9 | 10-09-2017 01:17 PM |
Highlight text and find next instance | DrDOS | Word | 0 | 11-15-2010 04:02 PM |
Lock words in a document, but allow for input within the document | tlinde | Word | 1 | 02-09-2010 09:07 PM |
FInd recurring words in Word 2003 | NJ007 | Word | 4 | 01-25-2010 03:11 PM |
find - reading highlight - highlight all / highlight doesn't stick when saved | bobk544 | Word | 3 | 04-15-2009 03:31 PM |