2007 和 2003 之间的 Microsoft 对象库兼容性

发布于 2024-10-01 08:52:39 字数 346 浏览 0 评论 0原文

我在 Excel 2007 中有一个与 Microsoft Word 交互的宏。我应用 Microsoft Word 12.0 对象库来访问必要的命令。但是,当 Office 2003 用户尝试使用该宏时,他会收到错误消息。这是因为 Office 2003 使用 Microsoft Word 11.0 对象库。 12.0 库被视为丢失。

如果我使用 11.0 对象库保存 2003 年的文档,则一切正常。 2003 和 2007 用户都可以使用该宏。但2007年似乎自动将11.0对象库更新到12.0。因此,如果用户在 2007 年保存文档并尝试将其传回 2003 年的用户,该功能将再次中断。

有没有办法让VBA在使用2003时引用11.0?

I have a macro in Excel 2007 that interacts with Microsoft Word. I apply the Microsoft Word 12.0 Object Library in order to access the necessary commands. However, when an Office 2003 user tries to use the macro, he gets an error. This is because Office 2003 uses the Microsoft Word 11.0 Object Library. The 12.0 library is seen as missing.

If I save the document in 2003 with the 11.0 Object library, everything works fine. Both 2003 and 2007 users are able to use the macro. But 2007 seems to automatically update the 11.0 object library to 12.0. Thus if a user saves the document in 2007 and tries to pass it back to a 2003 user, the functionality will break once again.

Is there a way to tell VBA to reference 11.0 when using 2003?

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

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

发布评论

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

评论(1

薄暮涼年 2024-10-08 08:52:39

您可以使用后期绑定。删除对 Word 库的引用并使用:

Dim ws As Object

Set ws=CreateObject("Word.Application")

您需要将所有内置 Word 常量更改为值。您可以在删除库引用之前找到这些值,方法是

?wdDocument

在立即窗口中键入,或者使用对象浏览器。

You can use late binding. Remove the reference to the Word library and use:

Dim ws As Object

Set ws=CreateObject("Word.Application")

You will need to change all built-in Word constants to values. You can find the values before you remove the library reference by typing say,

?wdDocument

Into the immediate window, or by using the Object Browser.

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