Excel & PowerPoint AddIn

J

Jialiang Ge [MSFT]

Hello Dave,

From your post, my understanding on this issue is: you want to know how to
extend a Word COM add-in to Excel and PowerPoint. If I'm off base, please
feel free to let me know.

First, we need to add the registration entries of the add-in for Excel and
PowerPoint:
Right click the addin setup project,
View->Registry_.HKEY_LOCAL_MACHINE.Software.Microsoft.Office, then add the
entries for Excel and PowerPoint.

Secondly, we need to edit the code of the add-in project. Excel and
PowerPoint do not have "documents". Excel has Workbooks and PowerPoint
contains Presentations. If we need to access the contents of different
Office applications, we need to

1. Determine the current application type by using
Type applicationType = applicationObject.GetType();
string appName = (string)applicationType.InvokeMember( "Name",
BindingFlags.GetProperty, null, applicationObject, null);
2. Call Type.InvokeMember on different Office object models
(http://msdn2.microsoft.com/en-us/library/de3dhzwy.aspx).

For Excel Object Model, please refer to the MSDN articles in
http://msdn2.microsoft.com/en-us/library/aa272254(office.11).aspx
For PowerPoint, see
http://msdn2.microsoft.com/en-us/library/aa213568(office.11).aspx.

Here is an example about how to build a shared add-in for Word and Excel
for your reference
http://msdn2.microsoft.com/en-us/library/aa159658(office.11).aspx

Please let me know if you have any other concerns, or need anything else.

Sincerely,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
For MSDN subscribers whose posts are left unanswered, please check this
document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express/Windows Mail, please make sure
you clear the check box "Tools/Options/Read: Get 300 headers at a time" to
see your reply promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jialiang Ge [MSFT]

Hi Dave,

Would you mind letting me know the result of the suggestions? If you need
further assistance, feel free to let me know. I will be more than happy to
be of assistance.

Have a great day!

Sincerely,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jialiang Ge [MSFT]

Hello Dave,

Word, Excel and PowerPoint have different events for "New Document". Word
has NewDocument event
(http://msdn2.microsoft.com/en-us/library/aa157539(office.10).aspx), Excel
has NewWorkbook
(http://msdn2.microsoft.com/en-us/library/aa200620(office.10).aspx) and
PowerPoint has NewPresentation
(http://msdn2.microsoft.com/en-us/library/aa211556(office.11).aspx).
Because the add-in project is a shared add-in, we need to register the
right event according to the current Office application. Please follow the
steps below to do it:

Step1. Determine the current application.
As we discussed in the first reply of the post, the application type could
be determined with the code:
Type applicationType = applicationObject.GetType();
string appName = (string)applicationType.InvokeMember( "Name",
BindingFlags.GetProperty, null, applicationObject, null);

Step2. Add the event handler with late binding.
If (appName.Contains("Word"))
{
// add the NewDocument event handler
// cast it to Word.ApplicationEvents4_Event object
ApplicationEvents3_Event aee =
(Word.ApplicationEvents4_Event)applicationObject;
aee.NewDocument += Event_WordNewDocument;
}
If (appName.Contains("Excel"))
{
// add the NewWorkbook event handler
// similar to the above, but we are using Excel.ApplicationEvents4_Event
here
// ¡­
}
If (appName.Contains("Power"))
{
// add the NewPresentation event handler
// similar to the above, but we are using
PowerPoint.ApplicationEvents4_Event here
// ¡­
}

If you have further questions or concerns, please feel free to let me know.

Sincerely,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jialiang Ge [MSFT]

Hello Dave,
If I open 4 copies of Word, they all use the
same instance of my AddIn program. Yes.

If I then open Excel is it also using that same
instance? Or does it create a seperate one
for Excel?
It uses a seperate instance of the add-in for Excel

If you have further question, please feel free to let me know.

Sincerely,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
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