I have some code in an Office VSTO addin (implemented for Word, Excel 2003 & 2007 in VB.NET) that is causing problems for some external automation code.
Is there a way I can determine whether an Office document has been opened by automation code, versus opened by a user? Some difference in the Application or Document objects, or an event I can handle that only fires in one or the other circumstance?
Ok, so when an Office application is opened through the Office Object Model, the command line uses the
/automationswitch (eg.Winword.exe /automation).So I’m just checking for this in the startup of my addin and setting a global Boolean:
I’ve got to do some testing to make sure there aren’t any other situations which might use that switch, but I think this will do the trick.