VBA Word 宏无法识别空格或通配符

发布于 2024-08-09 23:28:28 字数 350 浏览 10 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

铃予 2024-08-16 23:28:28

也许您需要将选项 .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 the Trim on line 63. If you want to use wildcards, you would need to have .MatchWildcards = True on line 233.

魂归处 2024-08-16 23:28:28

您可以尝试将 MatchWholeWord:=True 属性添加到 Execute 语句中。

它未经测试,但我相信会给你你想要的结果。

You might try adding the MatchWholeWord:=True property to your Execute statement.

It's untested, but I believe that will give you the results you want.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文