R – How to use COM in VBA for Word

comms-officems-wordvba

I am working with VBA, in Microsoft Office 2007 and 2003 (Word specifically).

What I need is to use a custom COM object from VBA and use its methods. I already do it in Word 2007 but it crashed in 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.

How to make it work for Office 2003?

Best Answer

You might need to use regsvr32 to register the COM component if you have just copied the file to the Word 2003 machine.

E.g.:

    regsvr32 yourcomfilesname.dll