简体   繁体   English

如何在 VBA for Word 中使用 COM?

[英]How to use COM in VBA for Word?

I am working with VBA, in Microsoft Office 2007 and 2003 (Word specifically).我在 Microsoft Office 2007 和 2003(特别是 Word)中使用 VBA。

What I need is to use a custom COM object from VBA and use its methods.我需要的是使用来自 VBA 的自定义COM object并使用它的方法。 I already do it in Word 2007 but it crashed in Word 2003.我已经在 Word 2007 中这样做了,但它在 Word 2003 中崩溃了。

This is the command that I am using:这是我正在使用的命令:

    Dim oCOM as Object.

    Set oCOM = CreateObject("COMDLL.COMObj")

I got this error:我收到了这个错误:

File or assembly name COMDLL, or one of its dependencies, was not found.找不到文件或程序集名称 COMDLL 或其依赖项之一。

How to make it work for Office 2003?如何使其适用于 Office 2003?

You might need to use regsvr32 to register the COM component if you have just copied the file to the Word 2003 machine.如果您刚刚将文件复制到 Word 2003 机器,您可能需要使用regsvr32注册 COM 组件。

Eg:例如:

    regsvr32 yourcomfilesname.dll

The Problem was not create the COM object, It was an Office bug so I fixed it with a Microsoft update for Office 2003.问题不是创建 COM object,这是一个 Office 错误,所以我使用 Microsoft 更新 Office 2003 修复了它。

Here is the update URL:这是更新 URL:

Update for Office 2003 (KB907417) Office 2003 更新 (KB907417)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM