ClaudiaHelpOnVSTO

Hi,
I am using Word 2003 and VSTO 2005.

I have a .doc solution deployed by the Publish Wizard. When I open this .doc file there is a custom toolbar with different buttons on it. When I click on the buttons the corresponding event handler is called and executed. So fare everything works perfectly fine!

Then I reopen an other instance of the same .doc file (so now I have two Word windows open which are customized by the same assembly). If I click on a button on the custom toolbar in the second Word window, nothing happens at all¡­. as if the event handlers have been de-activated!

Can anyone help me on this

Thanks a lot!
Claudia




Re: Visual Studio Tools for Office Inactive event handler on custom toolbar

Cindy Meister

Hi Claudia

1. Have you declared the buttons at the class level (just double-checking)

2. Have you assigned a unique string to the TAG property of each button Word uses this to keep track of buttons its MDI interrace.






Re: Visual Studio Tools for Office Inactive event handler on custom toolbar

ClaudiaHelpOnVSTO

Hi Cindy,

Thanks for your tip. I had actually defined all my buttons at class level but had forgotten to assign a unique string to the TAG property. Thanks a lot!!

But I still don¡¯t quite understand how assemblies work in Office.

If I open a .doc file (VSTO solution), the assembly I have created is loaded into the Office application and starts running. The assembly detects the StartUp event of my .doc file and calls the event handler, i.e. the ThisDocument_Startup() method.

Let¡¯s say that in my ThisDocument_Startup() method I instantiate a object A which has different attributes.

Later (the first .doc is still open) I reopen an other instance of the same .doc file (points to the same assembly). The ThisDocument_Startup() method is called once again. I will then instantiate the same object A but assign different values to its attributes!

My question is now, how can I access/distinguish between these two objects A while the two documents are opened

I thought that Office runs the assembly foreach document in a separat way. But by running my example I have realized that I was wrong¡­

Claudia





Re: Visual Studio Tools for Office Inactive event handler on custom toolbar

Cindy Meister

ClaudiaHelpOnVSTO wrote:

But I still don¡¯t quite understand how assemblies work in Office.

If I open a .doc file (VSTO solution), the assembly I have created is loaded into the Office application and starts running. The assembly detects the StartUp event of my .doc file and calls the event handler, i.e. the ThisDocument_Startup() method.

Let¡¯s say that in my ThisDocument_Startup() method I instantiate a object A which has different attributes.

Later (the first .doc is still open) I reopen an other instance of the same .doc file (points to the same assembly). The ThisDocument_Startup() method is called once again. I will then instantiate the same object A but assign different values to its attributes!

My question is now, how can I access/distinguish between these two objects A while the two documents are opened

I thought that Office runs the assembly foreach document in a separat way. But by running my example I have realized that I was wrong¡­

I can't explain the background on how all this works (I only understand it vageuly, myself), but take a look at these two threads. They may give you some insight

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1206919&SiteID=1

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=452978&SiteID=1

to summarize: you probably need to maintain your own collection of documents / objects.






Re: Visual Studio Tools for Office Inactive event handler on custom toolbar

ClaudiaHelpOnVSTO

Thanks Cindy. I've had a quick look on both posts... I hope the first post will help me solve the riddle...

Claudia