Here you go:
Code:
Dim vFindText, vReplText As String
Dim vColor As String
Dim x As Integer
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
For x = 1 To 3
Select Case x
Case Is = 1
vFindText = "Cat I"
vColor = wdRed
Case Is = 2
vFindText = "Cat II"
vColor = wdYellow
Case Is = 3
vFindText = "Cat III"
vColor = wdPink
End Select
vReplText = vFindText
With Selection.Find
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Format = True
.MatchCase = False
.Text = vFindText
.Replacement.Text = vReplText
.Replacement.Highlight = True
.Execute Replace:=wdReplaceAll
.Font.Color = vColor
End With
Next x
Now the text is something like this:
blah blah blah blah
blah blah blah blah
one or more blank lines
Heading
Cat I (or II or III)
blah
blah
blah
This scenario repeats throughout a 600+ page document. I would like to insert a page break before each Heading...I.e. go back 2 lines. But, I would also like to check for the existence of a page break before adding another one.
I tried various forms of Do...Loop, but I got myself into an endless loop. :-)
Thank you for your help.