正则表达式替换正文内容
我尝试以下方法将当前打开文档中的所有文本内容替换为数字零,但它不起作用
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")
任何人都可以建议一种工作方法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您引用了 microsoft vbscript 正则表达式
将会起作用,尽管您当然会丢失任何格式。
您还可以使用内置的搜索/替换,它对查找数字/字符的支持有限。录制您自己执行此操作的宏,然后您可以检查代码。
Assuming you have referenced microsoft vbscript regular expressions
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.