Has anyone any idea how to search word documents for selected keywords or phrases? The code snippet just simply tells me the word has been found, but I am trying to get the line of text where the word is present. Thanks
searchString = "TOURS"
With wrdDoc
For p = 1 To .Paragraphs.Count
startRange = .Paragraphs(p).Range.Start
endRange = .Paragraphs(p).Range.End
Set tRange = .Range(startRange, endRange)
tString = tRange.Text
tRange.Find.Text = searchString
tRange.Find.Execute
If tRange.Find.Found Then
Me.List0.AddItem searchString & " Is present"
End If
Next
.Close
End With
wrdApp.Quit
searchString = "TOURS"
With wrdDoc
For p = 1 To .Paragraphs.Count
startRange = .Paragraphs(p).Range.Start
endRange = .Paragraphs(p).Range.End
Set tRange = .Range(startRange, endRange)
tString = tRange.Text
tRange.Find.Text = searchString
tRange.Find.Execute
If tRange.Find.Found Then
Me.List0.AddItem searchString & " Is present"
End If
Next
.Close
End With
wrdApp.Quit