Access single COM server from AddInExpress module and Excel macros

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

Access single COM server from AddInExpress module and Excel macros
 
Alex




Posts: 1
Joined: 2011-06-30
Hi,

Suppose I'm developing Excel Addin which loads some COM server (does not matter now - inproc or out-of-proc) - the approporiate __ComObject instance (singleton) is saved as some static member value. I can successfully call this server's methods from task panes, from AddInExpress event handlers. etc. But: I can not use the same COM object from Excel macros (saym defined as butotn click, etc.) since this macro is executed in different appdomain! My question is if I can re-use (I do not how) existing COM server from macros? Can I (somehow) pass __ComObject instance from one appdomain to another?

Or, is it possible to use single appdomain for my application (I suppose it's AddInExpress who creates separate AppDomain)?

Thanks
Alex
Posted 30 Jun, 2011 05:37:59 Top
Andrei Smolin


Add-in Express team


Posts: 14094
Joined: 2006-05-11
Hi Alex,

Consider creating a public property or method providing access to that COM object and use that property/method in your macros:

ExcelApp.COMAddins.Item(strMyComAddinProgId).Object.MyPublicPropertyOrMethod.

1. strMyComAddinProgId - see the ProgId attribute of your add-in module.
2. MyPublicPropertyOrMethod is called via late binding

Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 30 Jun, 2011 06:35:31 Top