![]() |
|
|||||||
|
|
Thread Tools | Display Modes |
|
#2
|
||||
|
||||
|
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 |
| Tags |
| find & replace, vba code, word vba |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Duplicating Ranges and changing Font Attributes | CharlieM | Word VBA | 3 | 08-10-2021 04:44 AM |
Inserting page numbers manually in footer
|
msnarayanan | Word | 5 | 10-30-2018 06:30 AM |
VBA Code to search for field codes with certain text before the Field code and to change style
|
welcometocandyland | Word VBA | 4 | 02-08-2017 06:53 PM |
Inserting image into paragraph style
|
gnelz | Word | 1 | 02-07-2017 01:12 PM |
VBA code for inserting a future date
|
cosmopolitan | Word VBA | 1 | 08-14-2013 01:58 PM |