View Single Post
 
Old 01-27-2022, 11:19 AM
NLDLC NLDLC is offline Windows 10 Office 2021
Novice
 
Join Date: Jan 2022
Posts: 5
NLDLC is on a distinguished road
Default highlight text in array

Hi. I'm currently using the below VBA to find specific words (the myWords array) and then print those pages.

Code:
Sub PrintSpecificWords()
Dim myWords()
Dim j As Long
myWords = Array("Word1", "Word2", "Word3", "Word4", "Word5")

For j = 0 To UBound(myWords())
With Selection
.HomeKey Unit:=wdStory
With .Find
.ClearFormatting
Do While .Execute(FindText:=myWords(j), _
Forward:=True) = True
Application.PrintOut _
Range:=wdPrintCurrentPage
Loop
End With
End With
Next j
End Sub
I have attempted unsuccessfully to modify this to include additional code which would highlight the text found within the array after printing it (I plan to use this as to reconcile which pages have been printed).

Is there a way to do this using my existing "myWords" array?
Reply With Quote