Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Communication between two Excel COM add-ins
Hello all,
I need to communicate an Excel COM Add-in and a RTD automation server that run at the same time when I open Excel. I need the RTD server to get a reference to the COM add-in. To do that I do the following: In the COM Addin: class MyCOMAddin : Extensibility.IDTExtensibility2 { public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { ((COMAddIn)addInInst).Object = this; } } In the RTD: public int ServerStart(Excel.IRTDUpdateEvent CallbackObject) { Excel._Application app = (Excel._Application) Marshal.GetActiveObject("Excel.Application"); MyCOMAddin addin = (MyCOMAddin) applicationObject.COMAddIns.Item (ref progName).Object; // progName is "MyCOMAddin.Connect" } This approach works but has two problems: 1) Marshal.GetActiveObject("Excel.Application") may fail. So I may have to retry this operation and try to force that object to be registered. To do that I have to minimize and maximize the Excel window when the addin is loaded. 2) If I open a second Excel application (not another workbook, a new Excel instance). All this will fail. In particular, a new call to applicationObject.COMAddIns.Item(ref progName).Object will return a System.__ComObject that is not possible to cast to MyCOMAddin. I couldn't find anything to solve that, do you have any solution for these 2 issues? Thanks! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
excel, visual basic and serial communication | Excel Programming | |||
Excel macros for interprocess communication | Excel Programming | |||
Access/Excel Communication | Excel Programming | |||
communication between Excel files | Excel Programming | |||
Excel Communication | Excel Programming |