VBA Word 宏无法识别空格或通配符
我有一个 VBA Word 宏,它从 .txt 列表中获取单词,并在 word .doc 文档中用颜色突出显示它们。
问题在于该脚本忽略 .txt 列表中的空格和通配符。我插入了“wit”一词,但它也更改了 witHIN 、 witCHE 等单词。
我尝试在 .txt 文件中插入通配符,例如或使用“wit”等空格,但它不起作用。该脚本忽略空格和通配符。
代码在这里:http://pastebin.com/m3e20f932
Melissa。
I have a VBA Word Macro that gets words from .txt list and color highlight them in a word .doc document.
The problem is that the script ignores whitespaces and wildcards from the .txt list. I insert the word "wit" but it also changes words like witHIN , witCHE, etc.
I tried inserting wildcards in the .txt file, like or using white spaces like " wit ", but it didnt worked. The script ignore the whitespaces and the wildcards.
THE CODE IS HERE: http://pastebin.com/m3e20f932
Melissa.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许您需要将选项
.matchWholeWord = True
添加到第 233 行?如果您希望使用空格来完成此操作,则可以删除第 63 行上的Trim
。如果您想使用通配符,则需要将.MatchWildcards = True
设置为第233行。Maybe you need to add the option
.matchWholeWord = True
to line 233? If you would rather do it by using whitespace, you could remove theTrim
on line 63. If you want to use wildcards, you would need to have.MatchWildcards = True
on line 233.您可以尝试将
MatchWholeWord:=True
属性添加到Execute
语句中。它未经测试,但我相信会给你你想要的结果。
You might try adding the
MatchWholeWord:=True
property to yourExecute
statement.It's untested, but I believe that will give you the results you want.