We recently developed a VSTO customized Word template for a client. The client has now purchased a third party document management product which allows users to create a new document from the template. However, whenever the template is opened from the product, no customization code is executed.
I have discovered that the cause of this is the way the document management product launches Word (winword.exe). It uses the '/t' command line switch instead of the '/z' switch so the 'New' event is not firing (according to this article: ).
Unfortunately, it is not an option for us to change the command line switch which is used as this is hard-coded into the third party product.
Is there a way that our VSTO customization code can be invoked in this scenario I don't fully understand the complete process Word uses in launching the VSTO runtime and any customization assemblies, and in particular why the firing of the 'New' event is vital to the launching of the customization. Our code is included in the ThisDocument_Startup, ThisDocument_New and ThisDocument_Open methods but none of these are being called.

One configuration option that the document management product does give is that allows the user to specify a VBA macro which it will invoke whenever the new document has been opened. Do you think this could be used to somehow invoke the VSTO customization

Any suggestions you have would be much appreciated.



Re: Visual Studio Tools for Office Launching customized Word template from the command line

Helmut Obertanner

Hello Paul,

maybe this could be of interrest to you. PostID=224432&SiteID=1

Hope this helps,

greets, Helmut

Re: Visual Studio Tools for Office Launching customized Word template from the command line

Misha Shneerson - MSFT

Unfortunately, the way VSTO loader works is that it listens to either Document.New or Document.Open events and then it loads the customization. This is a design decision that we (VSTO team) had to make because accessing VSTO's Runtime Storage Control (where the assembly loading information is located) before Document.Open/New events caused Word to do very goofy stuff (the details are ecaping me for now though). Hence, if Document.New/Open is not raised - VSTO customization does not run.