Word VBA 访问自定义词典的内容
我需要检查Word文档中的各种代码。
这些代码通常是一个字母后跟一个连字符和 5 个数字,例如 M-81406。
我们需要检查这些预定义代码是否已正确输入(有数千个代码的预定列表)。 我们无法使用普通的 Word 拼写检查,因为您不能拼错数字(您至少需要 2 个字母)。
我想我可以编写 VBA 代码来查找任何可能无效的代码。 我可以使用正则表达式来检查它们。
我可以从 VBA 访问自定义词典的内容吗?
我需要一个可由客户轻松更新的解决方案。
任何提出巧妙地突出显示错误代码的方法的人都会获得奖励。
I need to check various codes in a Word document.
These codes are usually a letter followed by a hyphen and 5 digits, eg M-81406.
We need to check that these pre-defined codes have been typed in correctly (there is a pre-determined list of several thousand codes).
We cannot use normal Word spell checking as you cannot misspell a number (you need at least 2 letters).
I figured I could write VBA code that finds any that may be invalid. I can use regular expressions to check them.
Am I able to access the contents of a custom dictionary from VBA?
I need a solution that is to be updated by the client easily.
Bonus points to anyone who suggests a clever way of highlighting the incorrect codes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能知道,自定义词典只是一个包含单词的文本文件,因此请参考 Microsoft Scripting Runtime,并使用:
不理想,因为它会破坏下划线格式,并且不提供建议机制(尽管有一个小的建议)围绕列表框构建的表单就足够了)。
不幸的是,最好的解决方案是扩展拼写引擎。
A custom dictionary, as you probably know, is just a text file containing the words, so reference the Microsoft Scripting Runtime, and use:
Not ideal, because it clobbers underlining formatting, and doesn't provide a mechanism for suggestions (although a small form built around a listbox would suffice).
The best solution would involve extending the spelling engine, unfortunately.