Hello all,
I am using the following module to highlight specific words in my word documents:
Code:
Sub HiLightList()
Application.ScreenUpdating = False
Dim StrFnd As String, Rng As Range, i As Long
StrFnd = "cat,pig,dog,whatever"
For i = 0 To UBound(Split(StrFnd, ","))
Set Rng = ActiveDocument.Range
With Rng.Find
.ClearFormatting
.Text = Split(StrFnd, ",")(i)
.Replacement.ClearFormatting
.Replacement.Highlight = True
.Replacement.Text = "^&"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = True
.Execute Replace:=wdReplaceAll
End With
Next
Set Rng = Nothing
Application.ScreenUpdating = True
End Sub
It's working quite well but since I am working with thousands of Word pages of text a majority of which are irrelevant for me and contain zero information I need, I would like to know if there is a way i could somehow insert a code that would delete all pages that contain zero highlighted words? I don't need to extract only highlighted words, I need to preserve the whole text (specifically, it's 1-page-long newspaper articles) in which the highlighted words were found. Is there a simple way to do this and what would it be?
I am quite illiterate when it comes to coding or VBA or pretty much anything so I am relying on the kindness and skills of others willing to help me and write this down so I can simply insert it
Thank you!