VSTO - Word Execution

Hello all...

I have a question regarding the execution of a VSTO document I created.

For ease of demonstration, I stripped everything but a MessageBox with "Hello World" in the ThisDocument_Startup event...

Once deployed, if I manually open this document file, or if I open the document via a Process object within code, it works fine... All is well...

However, if attempt to open the document using the Word.Application object, the event never fires. For example:

Dim oWord as New Microsoft.Office.Interop.Word Application

Dim oFile as Microsoft.Office.Interop.Word.Document

oFile = oWord.Documents.Open("c:\DeployTest\Test.doc")

oWord.ShowMe()

....

Should this approach also execute the VSTO logic or am I missing something

...any information regarding this would be greatly appreciated.

Best Regards,

- Jon



Answer this question

VSTO - Word Execution

  • PaulDotNet

    This does work for me. I put a message box in my ThisDocument_Startup, published the solution to c:\deploytest, used caspol to grant FullTrust to c:\deploytest\*, then wrote a VB console app with your code, ran it and the message box showed up. So, this should work - except that oWord.ShowMe() does not make Word app visible - use oWord.Visible = True instead.

    Some wild guesses/tips:
    1. Possible another WINWORD instance is running on your machine and the process does not pick up changes to the CAS. Just make sure WINWORD process is not running.
    2. You can attach a managed debugger when WINWORD process starts up and see whether there are any exceptions. Here is a link that discusses how this can be done.

    Hope this helps.

    And, by the way, The VSTO team is hiring



  • VSTO - Word Execution