Greetings! I simply want to be able to use Regex within a VB script for Word.
Surely someone already has this script already written?
No, I don't want to use Word's built-in Find & Replace function including its "Wildcards" feature.
Code:
Sub LineCounter()
Dim regExp As Object
Set regExp = CreateObject("vbscript.regexp")
With regExp
.Pattern = "(^p^p)"
.Global = True
Selection.Text = .Replace(Selection.Text, "^p")
End With
End Sub
The above code kind of works, but I don't want to have to highlight text AND this code also unpredictably breaks the formatting of Word documents in which it is run.
Help, please!