Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
excel, visual basic and serial communication Peterken Excel Programming 1 July 5th 06 09:46 PM
Excel macros for interprocess communication venky Excel Programming 0 June 15th 06 04:13 PM
Access/Excel Communication andysgirl8800[_7_] Excel Programming 1 May 26th 06 06:36 PM
communication between Excel files cpliu Excel Programming 1 May 3rd 06 06:53 PM
Excel Communication Excel_Dumb Excel Programming 3 May 27th 05 10:05 AM


All times are GMT +1. The time now is 10:11 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"