I'm trying to devise a code to apply a specific style if the fnt ref number followed by a return is preceded by specific characters. I need help with the if-condition. Thanks!
Code:
Sub FormatThese()
Dim oRng As Range
Set oRng = ActiveDocument.Range
Do
With oRng.Find
.MatchWildcards = False
.Text = "^f^p" 'find this sequence
.Replacement.Text = ""
.Wrap = wdFindStop
.Execute
End With
'oRng.Select
'If found and sequence preceded by one of these characters: "!.?-–»" Then
'If oRng.Find.Found And oRng.Characters.Last.Previous = "[!.?-–»]" Then
If oRng.Find.Found Then
oRng.Style = "myStyle"
Else: Exit Do
End If
oRng.Collapse 0
Loop
Set oRng = Nothing
End Sub