View Single Post
 
Old 03-15-2019, 05:15 AM
Asuryan33 Asuryan33 is offline Windows 10 Office 2016
Novice
 
Join Date: Oct 2017
Posts: 9
Asuryan33 is on a distinguished road
Default Highlight sentences from a list located in another file

Hello all.

I'm trying to find a way to highlight word and sentences in a file from a list located in another file.

I found a a macro online but the problem is that it will highligh all single words.
What should I do if I want to highlight a list of strings composed of several words (Like phrasal verb or expression for exemple)
For exemple, I want it to highlight all "Fill out" but leaving alone all "fill" and "out" that are not a part of "Fill out"

Thank you

the Macro I found on https://wordribbon.tips.net/ is:

Sub CompareWordList()
Dim sCheckDoc As String
Dim docRef As Document
Dim docCurrent As Document
Dim wrdRef As Object

sCheckDoc = "c:\checklist.doc"
Set docCurrent = Selection.Document
Set docRef = Documents.Open(sCheckDoc)
docCurrent.Activate
Options.DefaultHighlightColorIndex = wdYellow

With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Replacement.Highlight = True
.Replacement.Text = "^&"
.Forward = True
.Format = True
.MatchWholeWord = True
.MatchCase = True
.MatchWildcards = False
End With

For Each wrdRef In docRef.Words
If Asc(Left(wrdRef, 1)) > 32 Then
With Selection.Find
.Wrap = wdFindContinue
.Text = Trim(wrdRef)
.Execute Replace:=wdReplaceAll
End With
End If
Next wrdRef

docRef.Close
docCurrent.Activate
End Sub
Reply With Quote