View Single Post
 
Old 11-07-2021, 12:34 AM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

It looks you were over-engineering this solution a bit
Code:
Sub SearchMultipleWords()
  Dim MyAr() As String, strToFind As String
  strToFind = "Background, Methods, Results, Conclusion"
  MyAr = Split(strToFind, ",")
  For i = LBound(MyAr) To UBound(MyAr)
    With ActiveDocument.Range.Find
      .ClearFormatting
      .Replacement.ClearFormatting
      .Text = MyAr(i)
      .Replacement.Style = "B12"
      .Forward = True
      .Wrap = wdFindContinue
      .Execute Replace:=wdReplaceAll
    End With
  Next i
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote