title: How can you tell programmatically if a Word Macro is signed from VB.Net/C#
body: <p>I have an VB.Net/C# application that programmatically:</p>
  
  <ol>
  <li>Creates an RTF document</li>
  <li>Open it up in Microsoft Word</li>
  <li>Runs a Word macro that exists in the Word Template using code like this:</li>
  </ol>
  
  <p>Code:    </p>
  
  <pre><code>Protected mobjWordApp As Word.Application = Nothing
  '
  ' lots more code snipped for clarity
  '
  With mobjWordApp.Dialogs.Item(Word.WdWordDialog.wdDialogToolsMacro)
      .Name = MacroName
      .Run = True
      .Execute()
  End With
  </code></pre>
  
  <p>This has worked happily for years.</p>
  
  <p>I now have a new requirement; My application is required to only run SIGNED Word Macros.</p>
  
  <p>This is easy enough to do in the Word user interface, as follows:</p>
  
  <pre><code>File &gt; Options &gt; Trust center &gt; Macro Settings
  Select "Disable all macros except digitally signed macros"
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/E6xF8.png" alt="Trust Center"></p>
  
  <p>Once this is set, if the person running Word displays the Macros dialog, any unsigned (or signed but untrusted) macros are not listed. This is all as I would expect.</p>
  
  <p>However, my VB.Net code, which is opening the Word Application can bypass this. When I run this code it will run a unsigned macro:</p>
  
  <pre><code>With mobjWordApp.Dialogs.Item(Word.WdWordDialog.wdDialogToolsMacro)
      .Name = MacroName
      .Run = True
      .Execute()
  End With
  </code></pre>
  
  <p>What I need to know is:</p>
  
  <p>Is there a way for my code to identify if a Macro is signed (and trusted) before I run it?</p>