Getting existing Excel instance in C# AddIn

Hippo Man

Member
Joined
Mar 23, 2006
Messages
12
I have written an AddIn for Excel using C# and COM Interop. It is working fine, but there is something that I want to do that I havent been able to find any information about.

I want to access the Application object for the current, existing spreadsheet from which the AddIn is being invoked. I know that I can do this to get an Application reference for a new Excel instance:
Code:
Excel.Application app = new Excel.Application();
However, I dont want a new instance; rather, I want the existing Application object that represents the Excel instance from which my C# AddIn is currently being invoked.

How do I get this current, existing Application instance from within the C# COM Interop code that implements my AddIn?

Thanks in advance.
 
P.S. -- I want to do this without any auxiliary macros or VBA code in the spreadsheet. I want all the logic to exist within the AddIn DLL that gets built from the C# COM Interop code, assuming this is possible. Thanks.
 
Back
Top