VB.Net 自动化 MS Word 的拼写检查功能

发布于 2024-07-07 15:38:02 字数 281 浏览 15 评论 0原文

当前正在开发的应用程序需要使用 MS Word 对应用程序中的某些文本区域执行拼写检查。

我目前拥有 Office 2007(即 Office 12 com 对象)。

我的问题是,如果我添加 Office 12 对象,在装有 Office 2003 的机器上会发生什么情况? 这既涉及其他开发盒也涉及最终用户。

我是否正确地相信最终结果将是这些用户无法使用咒语功能? 如果我使用 Office 11 对象,这是否意味着用户在安装了 Office 07 的情况下将无法执行拼写检查?

An application currently in development has the requirements for using MS Word to perform spell check on certain textareas within the application.

I currently have Office 2007 (which is the Office 12 com objects).

My question is, if I add in the Office 12 objects what will happen on boxes which have Office 2003? This is in regards to both other development boxes as well as the end users.

Am I correct in believing that the end result will be that the spell capabilities will not be available for those users? And if I used an Office 11 object would that mean that the users would be unable to perform the spellchecks if they have Office 07 installed?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(5

北风几吹夏 2024-07-14 15:38:02

我们放弃了尝试使用对 Word 的依赖项,因为两者都安装了不同的版本或根本没有安装 Office! 相反,选择 NetSpell

We gave up on trying to use a dependency on Word, as both have differing versions installed or no Office installation at all! Instead opting for NetSpell.

久伴你 2024-07-14 15:38:02

我在这里猜测,但如果是因为您无法在 2003 安装中使用 2007 PIA(主互操作程序集),您可以尝试通过反射访问 PIA,因为我猜想您想要的调用不会在两个,然后就没关系了 - 您将使用安装的那个。 如果您也正在安装 PIA,那么您可以让用户告诉您他们有哪些,或者更聪明一点,尝试 2007,如果失败,请尝试 2​​003。

就像我说的,我在这里猜测但这可能值得一试。

编辑:我找到了关于 Office PIA 的链接。 这里指的是 Excel,但实际上涵盖了一般的 Office。 我并不羡慕你所承担的任务。 看起来您需要检测 PIA(可能已安装也可能未安装)并采取相应的操作。 对我来说,这听起来像是一项需要反思的工作。

I am guessing here, but if it is as you can't use the 2007 PIA (Primary Interop Assembly) with a 2003 installation, you could try accessing the PIA via reflection as I would guess the calls you want won't change between the two, and then it won't matter - you'll use whichever is installed. If you are installing the PIA as well, you can then either get the user to tell you which they have, or be a little more clever and just try 2007 and if it fails, try 2003.

Like I said, I'm guessing here but it might be worth a try.

EDIT: I found this link about Office PIA's. This refers to Excel but actually covers Office in general. I don't envy the task you have. Looks like you'll need to detect the PIA (which may or may not be installed) and act accordingly. Sounds like a job for reflection to me.

回梦 2024-07-14 15:38:02

较新版本的 Office 将保持与旧版本 COM 对象的大部分(如果不是全部)兼容性。 这意味着如果您想针对 Office 2003 和 2007 进行编程,您将需要使用 Office 11 COM 对象作为依赖项,因为它们是 2003 发布时最新的可用对象。 只要您验证所需的方法是否存在两个版本的 COM 对象,只要您使用较旧的 COM 对象,就不会有任何问题。

不幸的是,虽然我在自己的工作中使用了这个解决方案,但我还没有使用拼写检查对其进行测试。 最后,请确保使用您希望集成的所有 Office 版本测试您的代码。

Newer versions of Office will maintain most if not all compatibility with older versions of COM objects. Meaning if you want to program against Office 2003 and 2007 you will need to use Office 11 COM objects as a dependency as they were the newest available when 2003 was released. As long as you verify that the methods you need exist both versions of COM objects you should have no problems as long as you use the older COM objects.

Unfortunately, although I have used this solution for my own work, I have not tested it with Spell Check. In the end make sure that you test your code with all version of Office that you wish to integrate with.

拔了角的鹿 2024-07-14 15:38:02

我对这个问题的本能反应是简单地建议你走另一条路。 尝试使用第三方拼写检查控件。 它们相对便宜(并且您可能会找到一些免费控件)。 至少这样您可以控制应用程序中包含的控件的版本并能够依赖它的功能。 坦白说,我很惊讶这个库还没有内置到 Windows 中。 当然,对于 Windows 支持的所有语言来说,这很复杂,但现在就用户期望而言,它与复制/粘贴类似。

My gut reaction to this question, is to simply suggest you go another route. Try using a 3rd party spell-check control. They are relatively inexpensive (and you may find some free controls). At least that way you can control the version of the control included with your app and be able to rely on it's functionality. Quite frankly, I'm surprised this library isn't built into Windows already. Sure it's complicated with all of the languages Windows supports, but these days it's similar to copy/paste in terms of user expectations.

留一抹残留的笑 2024-07-14 15:38:02

实际上,您可以打包在这两个版本中工作所需的 Office11 和 Office12 互操作。 这需要一些小工作,但我设法做到了。 我在注册表中进行检查以查看要调用哪个互操作,然后使用正确的版本执行拼写检查。 它甚至会检查您是否安装了 Word,并抛出错误警报,提示您在没有 Word 的情况下无法进行拼写检查。 我们必须使用 Word,因为我们需要使用 Office 中附带的医学词典。

搜索一下 interop 或 Com 包装器,我想您会发现可以相当轻松地使用两者。

You can actually package both the office11 and office12 interops needed to work in BOTH versions. It takes some minor work but I managed to do it. I do a check in the registry to see which interop to call and then executes the spell checking with the correct version. It even goes so far as to check if you have Word installed and throws an error alert that you can't spell check without having Word. We're tied to using Word due to the medical dictionary that's tied into Office we're required to use.

Do a search on interop or Com wrappers and I think you'll find you can use both fairly easily.

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