1
votes

I tried the following to replace all the text content in the current open document with numeric zero, but it doesn't work

Set objWdDoc = Word.Application.ActiveDocument

Set objWdRange = objWdDoc.Content

Dim re As New RegExp

re.Global = True
re.Pattern = "[a-z]"
re.IgnoreCase = True
objWdRange = re.Replace(objWdRange, "0")

Can anyone suggest a working method?

1

1 Answers

0
votes

Assuming you have referenced microsoft vbscript regular expressions

objWdRange.Text = re.Replace(objWdRange, "0")

Will work, although you will of course lose any formatting.

You can also use the built-in search/replace which has limited support to find digits/characters. Record a macro of yourself doing this and you can examine the code.