Announcement

Collapse
No announcement yet.

MS Office COM Addin Port

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Igor Dovgunyk
    replied
    Your class does not receiveinterface IDTExtensibility2with operatorINHERIT. I checked.Defineinterface IDTExtensibility2directly in classMyClassName.

    Leave a comment:


  • Ronald Zutz
    started a topic MS Office COM Addin Port

    MS Office COM Addin Port

    I am about to port a VB COM addin for MS Office to PB. I'm developing on Windows XP with Office 2002/XP.

    In VB, you create an ActiveX DLL. It has 1 public class, which implements the IDTExtensibility2 interface in MSADDNDR.DLL. When the Office app starts, it instantiates an instance of the class (based on Registry info). The class has 5 events, from which it receives notice of app startup, new documents, etc. You're working within the Office thread without the security and other hassles of macros.

    PB 9's new object compabilities seemed like the answer. Except... Word doesn't seem to like anyway I code it. Just a vague message about a run-time error occurred while loading the COM addin.

    I'm wondering if anyone else has tried this. Here's the key addin designer code from COM Browser:
    Code:
    ' Interface Name  : Int__IDTExtensibility2
    ' ClassID         : $CLSID_AddInDesignerObjects_Event__IDTExtensibility2
    ' ProgID          : $PROGID_AddInDesignerObjects_AddinInstance
    ' Version ProgID  : $PROGID_AddInDesignerObjects_AddinInstance1
    CLASS Class_Int__IDTExtensibility2 $CLSID_AddInDesignerObjects_Event__IDTExtensibility2 AS EVENT
        INTERFACE Int__IDTExtensibility2 $IID_AddInDesignerObjects_Int__IDTExtensibility2 
            INHERIT IDISPATCH
    
            METHOD OnConnection <1> (BYVAL Application AS IDISPATCH, BYVAL ConnectMode AS LONG, BYVAL AddInInst AS IDISPATCH, BYVAL _
            custom AS DWORD)
                ' Insert your code here
            END METHOD
    
            METHOD OnDisconnection <2> (BYVAL RemoveMode AS LONG, BYVAL custom AS DWORD)
                ' Insert your code here
            END METHOD
    
            METHOD OnAddInsUpdate <3> (BYVAL custom AS DWORD)
                ' Insert your code here
            END METHOD
    
            METHOD OnStartupComplete <4> (BYVAL custom AS DWORD)
                ' Insert your code here
            END METHOD
    
            METHOD OnBeginShutdown <5> (BYVAL custom AS DWORD)
                ' Insert your code here
            END METHOD
    
        END INTERFACE
    END CLASS
    From my PB DLL, here's the skeleton code for the class which Office instantiates:
    Code:
     CLASS MyClassName GUID$("{3B36C6FF-27B9-418B-B892-634D04C26816}") AS COM
    
        INTERFACE MyInterfaceName GUID$("{21D9EBD3-A067-474B-AB7B-8C98FA10C4BC}")
            INHERIT Class_Int__IDTExtensibility2, Int__IDTExtensibility2
    
            OVERRIDE METHOD OnConnection <1> (BYVAL Application AS IDISPATCH, BYVAL ConnectMode AS LONG, BYVAL AddInInst AS IDISPATCH, BYVAL custom AS DWORD)
                LogIt("OnConnection")
            END METHOD
    
            OVERRIDE METHOD OnDisconnection <2> (BYVAL RemoveMode AS LONG, BYVAL custom AS DWORD)
                LogIt("OnDisconnection")
            END METHOD
    
            OVERRIDE METHOD OnAddInsUpdate <3> (BYVAL custom AS DWORD)
                LogIt("OnAddInsUpdate")
            END METHOD
    
            OVERRIDE METHOD OnStartupComplete <4> (BYVAL custom AS DWORD)
                LogIt("OnStartupComplete")
            END METHOD
    
            OVERRIDE METHOD OnBeginShutdown <5> (BYVAL custom AS DWORD)
                LogIt("OnBeginShutdown")
            END METHOD
    
        END INTERFACE
    END CLASS
    I've tried variations on the interface inheritance, with no better results. Any suggestions would be appreciated. Sample code would be manna.

    Ron
Working...
X