Shared Addin for Word

K

Kaustav

Hi,

I've created a shared addin for MS Word 2003 in C#. The addin comprises of a
toolbar which loads and works fine for the very first instance of Word. For
subsequent instances of Word, the toolbar is visible but doesn't work. What
am I doing wrong here?
 
C

Cindy M.

Hi =?Utf-8?B?S2F1c3Rhdg==?=,
I've created a shared addin for MS Word 2003 in C#. The addin comprises of a
toolbar which loads and works fine for the very first instance of Word. For
subsequent instances of Word, the toolbar is visible but doesn't work. What
am I doing wrong here?
I posted an answer to your question in the VSTO newsgroup. Did it answer the
question for you? If not, please describe how the suggestions did not help.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
K

Kaustav

Hi Cindy,

I followed your post
(http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=838845&SiteID=1) about
CustomizationContext.

Dim wdApp as Word.Application
wdApp = CType(applicationObject, Word.Application)
wdApp.CustomizationContext = wdApp.ActiveDocument.CustomizationContext

I get an error on the 3rd line -

wdApp.CustomizationContext = wdApp.ActiveDocument.CustomizationContext

It says ActiveDocument doesn't have a CustomizationContext property. I have
also tried to set the CustomizationContext property to "this" or the
"application" object. However in this case, the toolbar disappears.

Is there anything else I can do to make the toolbar global, i.e make it
functional for all documents/windows?
 
C

Cindy M.

Hi =?Utf-8?B?S2F1c3Rhdg==?=,

Oops! Typo on my part.
wdApp.CustomizationContext = wdApp.ActiveDocument

Sorry about that...
I followed your post
(http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=838845&SiteID=1) about
CustomizationContext.

Dim wdApp as Word.Application
wdApp = CType(applicationObject, Word.Application)
wdApp.CustomizationContext = wdApp.ActiveDocument.CustomizationContext

I get an error on the 3rd line -

wdApp.CustomizationContext = wdApp.ActiveDocument.CustomizationContext

It says ActiveDocument doesn't have a CustomizationContext property. I have
also tried to set the CustomizationContext property to "this" or the
"application" object. However in this case, the toolbar disappears.

Is there anything else I can do to make the toolbar global, i.e make it
functional for all documents/windows?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
K

Kaustav

Hi Cindy,

yeah I tried that too, but it didn't help.

Following is how my code is arranged -

public void OnConnection(object application, Extensibility.ext_ConnectMode
connectMode, object addInInst, ref System.Array custom)

1. Assign the application object to a Word Application.
2. Create a toolbar.
3. Create some commandbar buttons for the toolbar.

Now I've put "wdApp.CustomizationContext = wdApp.ActiveDocument" just before
step 1. In this case, the toolbar is not visible and available at all.

If I put the same line of code after step 3, the toolbar is visible and
functional, but only for the very first instance of Word.

I've even tried out wdApp.CustomizationContext = wdApp.NormalTemplate but
that too didn't work.

Any other suggestions? Thanks.
 
C

Cindy M.

Hi =?Utf-8?B?S2F1c3Rhdg==?=,
yeah I tried that too, but it didn't help.

Following is how my code is arranged -

public void OnConnection(object application, Extensibility.ext_ConnectMode
connectMode, object addInInst, ref System.Array custom)

1. Assign the application object to a Word Application.
2. Create a toolbar.
3. Create some commandbar buttons for the toolbar.

Now I've put "wdApp.CustomizationContext = wdApp.ActiveDocument" just before
step 1. In this case, the toolbar is not visible and available at all.

If I put the same line of code after step 3, the toolbar is visible and
functional, but only for the very first instance of Word.

I've even tried out wdApp.CustomizationContext = wdApp.NormalTemplate but
that too didn't work.
And why not put Customizationcontext assignment between steps 1 and 2? That
would be the appropriate position, assuming "ActiveDocument" already exists.

But note if you make the customization in ActiveDocument it will be available
ONLY to that document.

NormalTemplate should work...

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
C

Cindy M.

Hi =?Utf-8?B?S2F1c3Rhdg==?=,
I am not considering the CustomizationContext w.r.t the ActiveDocument since
it will not be available for other document/windows. And NormalTemplate
doesn't work for me. Is there anything else I can do to get this working? Or
would you know of any sample code which details how to create an add-in which
works globally for Word as a whole?
The "best" way to do something like this is to deliver a Word template as part
of your Add-in. Do the toolbar customizations in that. If the customizations are
more or less static you can create them in the template (you wouldn't need to
create/destroy every time the addin loads/unloads) and just hook up the events
on loading.

Your Add-in can first load the template as an Add-in (Application.Addins.Add -
read the Help for this method carefully), then hook up the events to the
commandbars.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
K

Kaustav

Thanks Cindy, will check that up.

Cindy M. said:
Hi =?Utf-8?B?S2F1c3Rhdg==?=,

The "best" way to do something like this is to deliver a Word template as part
of your Add-in. Do the toolbar customizations in that. If the customizations are
more or less static you can create them in the template (you wouldn't need to
create/destroy every time the addin loads/unloads) and just hook up the events
on loading.

Your Add-in can first load the template as an Add-in (Application.Addins.Add -
read the Help for this method carefully), then hook up the events to the
commandbars.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)


This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 

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