I'm struggling to find a way to loop through every word in a Word document and make the word bold if it's in a list of predefined words/terms. The predefined list is in strCollection
.
Sub BoldWords()
Dim strCollection(2) As String
strCollection(0) = "test"
strCollection(1) = "john"
strCollection(2) = "later"
For Each strWord In ActiveDocument.Words
'If the strWord is in the strCollection
'strWord.Font.BOLD = True
'End If
Next strWord
End Sub
I can loop through the words okay, but I can't seem to figure out how to do the conditional logic to check if the word is in an array. I don't do a lot of VBA so I appreciate any help here.
I've looked at other answers to this question like this one but they don't run at all. Maybe they're for older versions of Word? I'm on O365.