Word/Excel/... AddIn - how do I know if it's Excel

D

David Thielen

I have an AddIn that is loaded by both Word and Excel. It's code is:

public void OnConnection(object application, Extensibility.ext_ConnectMode
connectMode, object addInInst, ref System.Array custom)
{
applicationObject = application;
...
public void OnStartupComplete(ref System.Array custom)
{
applicationType = applicationObject.GetType();
...

When I run the above using Word I get a type of {Name = "ApplicationClass"
FullName = "Microsoft.Office.Interop.Word.ApplicationClass"} which makes
sense.

But when I run under Excel I get a type of {Name = "__ComObject" FullName =
"System.__ComObject"} which could be anything. How do I get an application
object of type Microsoft.Office.Interop.Excel.ApplicationClass?

I need the Microsoft.Office.Interop.Excel.ApplicationClass object not only
to determine if I am under Excel but also to set events like workbook
creation.

This is a continuation of my earlier post on this - that post was getting
long enough that I think it makes sense to restart.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top