更新 VB6 应用程序中的 OLE 参考

发布于 2024-10-31 12:38:18 字数 296 浏览 5 评论 0原文

我有一个旧的 vb6 应用程序,我负责维护它,它可以将 Word 文档保存、打开和打印到用户计算机。有一天,当我们从 Office 2003 切换到 Office 2010 时,我开始收到投诉,称该软件不再打开保存的报告并打印它们。删除 Office 2010 并安装 2003 可以解决该问题。

处理这个问题的子过程都是普通的msdn代码,我找不到任何将其与特定版本的Word联系起来的东西。我的下一个想法可能是 OLE dll 引用。在哪里/如何更新对 dll 的 VB6 引用以与新版本的 Office 一起使用?

任何其他建议将不胜感激。

I have an old vb6 app that I'm in charge of maintaining that saves, opens, and prints Word documents to a users computer. The other day when we switched from office 2003 to office 2010, I started to get complaints that the software would no longer open saved reports and print them. Removing Officer 2010 and installing 2003 fixes the problem.

The sub procedure that handles this is all vanilla msdn code and I'm unable to find anything that would tie it to a certain version of Word. My next thought is perhaps its the OLE dll reference. Where/how can I update the VB6 reference to the dll to work with the new version of office?

Any other suggestions would be greatly appreciated.

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

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

发布评论

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

评论(3

离不开的别离 2024-11-07 12:38:18

我不确定,但据猜测,听起来您正在尝试使用早期绑定。如果是这样,这可能是您的问题。

十多年来,有大量 MS 知识库文章对此发出警告。示例:

http://support.microsoft.com/kb/247579

http://support.microsoft.com/kb/245115

换句话说:删除对任何版本 Word 的所有引用,声明所有对象As Object,并在适当的情况下使用CreateObject()GetObject()而不是Set Obj = New LibName。类名

这些知识库文章现在已经过时了,让您无需参考 Word 95 进行编译并仍然自动执行 Word 2002 的旧规则似乎不再适用。除了需要在您的开发计算机上安装受支持的最旧版本的 Office 之外,我怀疑从 Office 2003 开始​​向上兼容性就被破坏了。

您最好的选择是后期绑定。对于大多数程序来说,性能损失很小,因此最令人头痛的是失去 IntelliSense。

I'm not sure but as a guess it sounds like you are trying to use early binding. If so this is likely your problem.

There are numerous MS KB articles warning about this over a period of over a decade. Examples:

http://support.microsoft.com/kb/247579

http://support.microsoft.com/kb/245115

In other words: remove all references to any version of Word, declare all of the objects As Object, and use CreateObject() or GetObject() where appropriate instead of Set Obj = New LibName.ClassName.

These KB articles are old now, and the old rules that let you get away with compiling with a reference to Word 95 and still automate Word 2002 don't seem to apply anymore. Besides needing the oldest supported version of Office installed on your dev machine, I suspect upward compatibility was broken beginning in Office 2003.

Your best bet is late binding. The performance penalty is minimal for most programs so the biggest headache is losing IntelliSense.

鹿港小镇 2024-11-07 12:38:18

如果您只是盲目地更新参考,您可能会中断对 Office 2003 的支持。如果这不是问题,那就继续吧。

如果是,您需要缩小应用程序失败的具体位置。不同版本之间的自动化模型版本之间存在一些细微差别。虽然不多,但它们就在那里。

最有可能的是,该代码正在以一种特定于 2003 年的方式执行某些操作。MS 在保持向后兼容性方面做得相当好,但它们并不是 100%

If you just blindly update the reference, you'll likely break support for Office 2003. if that's not a problem, go for it.

if it is, you'll need to narrow down where in particular, the app is failing. There are some minor differences between revs of the automation model between versions. Not a lot, but they are there.

Most likely, the code is doing something in a way that makes it specific to 2003. MS does a pretty good job of maintaining backwards compat, but they aren't 100%

一直在等你来 2024-11-07 12:38:18

要回答您的问题“在哪里/如何更新对 dll 的 VB6 引用以与新版本的 Office 一起使用?”:您当然需要一台安装了 Office 2010 和 VB 6 的计算机。如果在 VB IDE 中打开项目,则可以更改对适当 Word 库的引用。 VBP 文件中也注明了引用,例如这样

Type=Exe
Reference=*\G{00020905-0000-0000-C000-000000000046}#8.0#409#C:\Program Files\Microsoft Office\OFFICE11\MSWORD.OLB#Microsoft Word 8.0 Object Library
Reference=*\G{00025E01-0000-0000-C000-000000000046}#4.0#0#C:\Program Files\Common Files\Microsoft Shared\DAO\DAO350.DLL#Microsoft DAO 3.51 Object Library
Reference=*\G{420B2830-E718-11CF-893D-00A0C9054228}#1.0#0#C:\WINDOWS\system32\SCRRUN.DLL#Microsoft Scripting Runtime

然后重新编译。
好吧,如果您在那里,您可以开始调试并查看详细情况以及报告失败的原因。如果这是您的问题,则无法在不重新编译的情况下更改引用。

如果它是与打开、保存和打印相关的普通代码,则很难想象会出现问题。

另一方面 - 是否有使用的 Word 格式的“基本文件”?可能他们有一个旧的格式(来自 Office 95,最近才看到这个)。尝试手动打开这些文件,看看会发生什么。

To answer your question "Where/how can I update the VB6 reference to the dll to work with the new version of office?": You need of course a computer with Office 2010 and VB 6 installed. If you open the project in the VB IDE, you can change the reference to the appropriate Word Library. The references are also noted in the VBP file, e.g. like this

Type=Exe
Reference=*\G{00020905-0000-0000-C000-000000000046}#8.0#409#C:\Program Files\Microsoft Office\OFFICE11\MSWORD.OLB#Microsoft Word 8.0 Object Library
Reference=*\G{00025E01-0000-0000-C000-000000000046}#4.0#0#C:\Program Files\Common Files\Microsoft Shared\DAO\DAO350.DLL#Microsoft DAO 3.51 Object Library
Reference=*\G{420B2830-E718-11CF-893D-00A0C9054228}#1.0#0#C:\WINDOWS\system32\SCRRUN.DLL#Microsoft Scripting Runtime

Then recompile.
Well, and if you are there, you can just start to debug and see, what happens in detail and why the reports fail. There's no way to change the reference without recompiling, if this was your question.

If it's plain vanilla code related to open, save and print, it's hard to imagine something going wrong.

On the other hand - are there any "base files" in Word format, which are used? May be they have an old format (from Office 95, have just seen this lately). Try to open those files manually and see what happens.

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