Accessing an Excel Addin Module from another Addin

Add-in Express™ Support Service
That's what is more important than anything else

Accessing an Excel Addin Module from another Addin
 
Elliot Sullivan




Posts: 2
Joined: 2010-08-04
We recently purchased Add-in Express and would like to make use of the ADXExcelAddinModule so that we can use UDFs in our application. We have an existing Add-in project and would like to pass a parameter to the new Add-in Express Excel Add-in Module class. From what I have read, this is possible but it is not working for us. I suspect I may be going about this incorrectly, so any help or suggestions would be greatly appreciated. For ease's sake, I made a test solution to recreate the issue. Here are my steps:

1. Created a new solution and added an Excel 2007 Add-in project (not using Add-in Express, just a standard Excel Add-in).

2. Added an ADX COM Add-in project and added an ADXExcelAddinModule class to it.

3. Added the following function to the ADXExcelAddinModule class:

public int test(int num)
{
return num * 100;
}

4. Registered the ADX Project and tested that the "test" function worked.

5. In the initial addin project, added the following code to startup to access the ADXExcelAddinModule class (verified that "MyAddin1.ExcelAddinModule1" is the correct ProgID):

string test = this.Application.COMAddIns.Item("MyAddin1.ExcelAddinModule1").Description;

This line crashes with a COMException (Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))).

So, I'm not sure what to do at this point. Given that we ideally want to be able to use UDFs within our existing Addin, am I even going in the right direction? Add if so, any thoughts on the crash?

Thanks!
Posted 04 Aug, 2010 10:48:25 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Elliot,

Please use the AddIns collection instead. For example:

string test = this.Application.AddIns.Item("MyAddin1.ExcelAddinModule1").Description;
.NET, Extended MAPI, Windows Phone & RT
Posted 05 Aug, 2010 07:10:12 Top
RemDev




Posts: 2
Joined: 2010-08-04
Thanks for the reply Eugene.

I tried the code you suggested but had to modify a bit for it to compile:

string test = this.Application.AddIns.Item["MyAddin1.ExcelAddinModule1"].Name;

Unfortunately I still get a COMException (Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))).

Maybe there is a setting I am missing?

Thanks!
E
Posted 05 Aug, 2010 07:32:32 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Elliot,

I have just checked it out, the following line of code works like a charm on my PC with Excel 2007 SP2:

string test = this.Application.AddIns.get_Item("MyAddin10.ExcelAddinModule1").Name;


Moreover, I have sent a complete solution to you. Please check out your Inbox.
.NET, Extended MAPI, Windows Phone & RT
Posted 05 Aug, 2010 08:04:36 Top