![]() |
#2
|
||||
|
||||
![]()
The code you posted assumes Word's highlighting has already been set to whatever highlights you want to use; if it's set to 'no highlighting, that's what you'll get. Try:
Code:
Sub FindAndHighlight() Application.ScreenUpdating = False Options.DefaultHighlightColorIndex = wdBrightGreen Dim StrFnd As String, i As Long, StrRpt As String StrFnd = "tasks,architecture,java" With ActiveDocument.Range.Find .ClearFormatting .Replacement.ClearFormatting .Replacement.Highlight = True .Forward = True .Wrap = wdFindContinue .Format = True .MatchCase = False .MatchWholeWord = True .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = True For i = 0 To UBound(Split(StrFnd, ",")) .Text = Split(StrFnd, ",")(i) .Replacement.Text = "^&" .Execute Replace:=wdReplaceAll If .Found = True Then StrRpt = StrRpt & vbCr & Split(StrFnd, ",")(i) Next End With If StrRpt = "" Then MsgBox "None of the terms were found.", vbOKOnly Else MsgBox "The following terms were found:" & StrRpt, vbInformation End If Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Tags |
find word highlight para, search, word vba |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
dmreno | Word VBA | 3 | 07-30-2019 02:31 PM |
Search the words of different document | Sandhya | Word | 15 | 11-24-2014 01:29 PM |
Macro to Search for all words with (R) and place in new document | kd12 | Word VBA | 2 | 06-10-2014 02:25 PM |
![]() |
netchie | Word VBA | 6 | 08-28-2012 03:37 PM |
![]() |
icsjohn | Word VBA | 2 | 12-07-2011 06:44 PM |