title: Programmatically configuring MS-Word's Trust Center settings using C#
body: <p>I have developed a simple C# Winforms application that loads MS-Word 2007 documents via COM automation. </p>
  
  <p>This is all very simple and straight forward, however depending on the document I need to programamtically Enable or Disable Macros as well as ActiveX controls.</p>
  
  <p>There is probably a way to store this in the registry, but I want to control these settings on an instance by instance basis as multiple concurrent requests may be running at a time.</p>
  
  <p>So my question is '<em>how do I configure the trust center settings using COM automation</em>'.</p>
  
  <p>I have Googled for hours, but all I have been able to find is the Application.AutomationSecurity property, but this only accepts the following values:</p>
  
  <ul>
  <li>MsoAutomationSecurity.msoAutomationSecurityLow</li>
  <li>MsoAutomationSecurity.msoAutomationSecurityForceDisable</li>
  <li>MsoAutomationSecurity.msoAutomationSecurityByUI</li>
  </ul>
  
  <p>The Word 2007 Trust Center however exposes the following settings:</p>
  
  <p>Macro Settings:</p>
  
  <ul>
  <li>Disable all macros without notification (matches msoAutomationSecurityForceDisable)</li>
  <li>Disable all macros with notifications (I don't need this one)</li>
  <li>Disable all macros except digitally signed macros (No equivalent)</li>
  <li>Enable all macros (matches msoAutomationSecurityLow)</li>
  </ul>
  
  <p><a href="https://i.stack.imgur.com/ZezzV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZezzV.png" alt="alt text"></a><br>
  <sub>(source: <a href="http://www.visguy.com/wp-content/uploads/2007/05/v2007-security-settings.png" rel="nofollow noreferrer">visguy.com</a>)</sub>  </p>
  
  <hr>
  
  <p>ActiveX controls (configured separately, I have not found any way to control these, note that according to the screenshot these settings are shared between all applications)</p>
  
  <ul>
  <li>Disable all controls without notification</li>
  <li>Prompt me before enabling UFI controls....</li>
  <li>Prompt me before enabling all controls with minimal erstrictions</li>
  <li>Enable all controls without restrictions</li>
  </ul>
  
  <p><img src="https://www.mathworks.com/access/helpdesk/help/toolbox/slvnv/ug/activex_settings.gif" alt="alt text"></p>
  
  <p>I have tried the old trick of recording an MS-Word macro while changing these settings, but none of these steps are recorded.</p>
  
  <p><strong>Update:</strong>
  I have found the following entries for the ActiveX controls settings in the registry. Looks like ActiveX settings are indeed global and cannot be specified for a single MS-Word instance unless someone proves me wrong.</p>
  
  <p>ActiveX Disabled</p>
  
  <p>[HKEY_CURRENT_USER\Software\Microsoft\Office\Common\Security]
  "DisableAllActiveX"=dword:00000001
  "UFIControls"=dword:00000002</p>
  
  <p>ActiveX Enabled with safe mode</p>
  
  <p>[HKEY_CURRENT_USER\Software\Microsoft\Office\Common\Security]
  "DisableAllActiveX"=dword:00000000
  "UFIControls"=dword:00000002</p>
  
  <p>ActiveX Enabled without safe mode</p>
  
  <p>[HKEY_CURRENT_USER\Software\Microsoft\Office\Common\Security]
  "DisableAllActiveX"=dword:00000000
  "UFIControls"=dword:00000001</p>
  
  <p>Still keen to resolve the macro settings problem</p>