HOWTO: Determine Application Type

R

Rob Lorimer

I tried to find this out today, but couldn't find any answered posts (it's
been asked numerous times!

In the OnConnection method:

if( application is Interop.Excel.Application )
{
MessageBox.Show("Excel Application");
}
else if( application is Interop.Access.Application )
{
MessageBox.Show("Access Application");
}

You need to reference Interop.Excel, Interop.Access and System.Windows.Forms
for this example.
 
P

Peter Huang [MSFT]

Hi

Based on my test, the code below works on my side.
Have you installed the PIA?
If you are using office 2003, the PIA is shipped with office 2003
installation.
If you are using office xp, the PIA can be download via the link below.
http://www.microsoft.com/downloads/details.aspx?FamilyId=C41BD61E-3060-4F71-
A6B4-01FEBA508E52&displaylang=en

public void OnConnection(object application,
Extensibility.ext_ConnectMode connectMode, object addInInst, ref
System.Array custom)
{
applicationObject = application;
addInInstance = addInInst;
if(application is Access.Application)
{
System.Diagnostics.Debug.WriteLine("Access.Application");
System.Windows.Forms.MessageBox.Show("Access.Application");
}
else if(application is Excel.Application)
{
System.Diagnostics.Debug.WriteLine("Excel.Application");
System.Windows.Forms.MessageBox.Show("Excel.Application");
}
}

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
R

Rob Lorimer

Sorry Peter,

My post was just a comment on how to do it ie I have it working and I was
telling others. The question of how to do this was asked many times with no
answer ... I was providing the answer :)
 
P

Peter Huang [MSFT]

Hi

Sorry for misunderstanding your meaning. :)
Also thank for sharing the knowledge in the community.

If you still have any concern, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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