I am using this code within access, to search a word document for mathing words typed in Text0.
It only highlights the first found word. Any ideas how I can make it highlight all found words. A real gem would also be to highlight and extract into strings the whole paragraph containing the word searched for. Many thanks.
Set WD = CreateObject(Class:="Word.Application")
WD.Visible = True 'False 'True
'Open the Document
WD.Documents.Open Filename:=LWordDoc, ReadOnly:=True
WD.Selection.Find.ClearFormatting
With WD.Selection.Find
.Text = Me.Text0
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
WD.Selection.Find.Execute
If WD.Selection.Find
It only highlights the first found word. Any ideas how I can make it highlight all found words. A real gem would also be to highlight and extract into strings the whole paragraph containing the word searched for. Many thanks.
Set WD = CreateObject(Class:="Word.Application")
WD.Visible = True 'False 'True
'Open the Document
WD.Documents.Open Filename:=LWordDoc, ReadOnly:=True
WD.Selection.Find.ClearFormatting
With WD.Selection.Find
.Text = Me.Text0
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
WD.Selection.Find.Execute
If WD.Selection.Find