Jump to content

Using VB Regex feature on Word,tried to replace 'the' and 'this' with 'that' but fail


Recommended Posts

Posted

I tried to replace 'the' and 'this' with 'that' by using VB Regex feature on Word upon the applied strings (ie. document) having font size mostly 10 and 18 for titles, but it resulted in entire strings having font size 18, although the regex seems works correctly (I can't read well)

 

Sub Regex_Replace

Dim re As Object, match As Object, matches As Object

Set re = CreateObject("VBScript.RegExp")

With re

.Global = True

.IgnoreCase = True

.Pattern = "(th)(e|is)\b"

ActiveDocument.Range.Text = .Replace(ActiveDocument.Range.Text, "$1at")

End With

End Sub

 

I can't read the document now as it got messed up and screwed with crammed words with font size 18.

Any idea, how to solve it?

Sincere help would really be appreciated

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...