Prevent Word macro in Normal.dotm for some templates
<p>I have a Normal.dotm file that contains an <code>AutoNew</code> macro.
This macro is automatically executed each time a new document is created using any other template.</p>

<p>Is there any way I can prevent this automatic behavior for a specific template?
I have a Word <code>VSTO</code> add-in running, so I can hook into Word's events, but so far I havn't found a way to prevent this.</p>

<p>I do know that I can prevent macro execution when using templates programmatically, for example like this:</p>

<pre><code>' Disable auto-macros before opening document
wordApplication.WordBasic.DisableAutoMacros(1)

' Open document
newWordDocument = wordApplication.Documents.Open(template.FullName, ConfirmConversions:=False, [ReadOnly]:=True, AddToRecentFiles:=False, Revert:=True)

' Re-enable auto-macros
wordApplication.WordBasic.DisableAutoMacros(0)
</code></pre>

<p>But this solution doesn't work when the user uses a Word template from Windows explorer or the Open-dialog in Word, since in those cases I can't execute code before it's too late already.</p>

<p>Or can I?
I hope someone has a trick for me :-)</p>

<p>-</p>

<p><strong>Edit</strong>: While trying different solutions, I discovered something that might help others in similar situations, though unfortunately it doesn't help me.
It seems that if a template contains a module containing an <code>AutoNew</code> (or <code>AutoOpen</code> for that matter), that local macro is executed instead of the one in <code>Normal.dotm</code>.  </p>

<p>Example:  </p>

<p>Normal.dotm contains the following macro:</p>

<pre><code>Sub AutoNew()
    MsgBox "Normal.dotm"
End Sub
</code></pre>

<p>Test.dotm contains the following macro:</p>

<pre><code>Sub AutoNew()
    MsgBox "Test.dotm"
End Sub
</code></pre>

<p>When executing <code>Test.dotm</code> the message "Test.dotm" is displayed, while the message "Normal.dotm" is not displayed.<br>
If the <code>AutoNew</code> macro is removed from the <code>Test.dotm</code> template, the message "Normal.dotm" is indeed displayed.</p>

<p>So it <em>is</em> possible to easily override the auto-macros.<br>
The local versions of <code>AutoNew</code> and <code>AutoOpen</code> can even be empty subs that do nothing. It still works.</p>

<p>This is not possible in my case though, since the template I use is generated by code, and cannot contain macros (because adding macros to templates programmatically requires the user to manually activate the option "Trust access to the VBA project object model", and that's something I cannot ask my customers to do for all users. It's also a security risk.)</p>