Eric van Feggelen

Hello everyone,

I've been playing with VSTO for Office 2007 for a couple of days now, but I cannot seem to get the desired results. The far most important issue I am currently having is that I do not know how to access my ThisDocument instance from my ThisAddin class. I've been using the ThisAddin.Application.ActiveDocument property to get a handle to my Word template, however the object returned is a Microsoft.Office.Interop.Word.Document instance, and not the instance I have created using VSTO. (Microsoft.Office.Tools.Word.Document)

The reason I want to execute my own code is because I have a taskpane at the application level that allows the user to bind a business entity to the template. This functionality should be that same for each template, and I refuse to duplicate the code for each individual template.

I've tried to use an interface to publish a couple of specific methods from the ThisDocument class. But the interface doesn't come out of the Interop.Word class. Even overriding the ToString() method with custom code isn't called from the Interop.Word class.

So the main question is; how do I access my custom document class instance from a application addin

Many thanks .. Smile



Re: Visual Studio Tools for Office VSTO Word addin and document template

Eric van Feggelen

BUMT

.... (Bring Up My Thread) Smile





Re: Visual Studio Tools for Office VSTO Word addin and document template

Saurabh Bhatia - MSFT

It is not possible to access a VSTO customized document from an add-in.

For the scenario you describe maybe you can use Actions Pane for all your templates instead of Custom Task Panes.

You can abstract out the common code for the Actions Pane in the Usercontrol and reuse the same Usercontrol for the Action Panes in all your templates.

Hope thats helpful.