title: Deploying Word Macro-Enabled Template (.dotm) with a Custom UI Ribbon
body: <p>I have built a Word Macro-Enabled Template (.dotm) that works perfectly on my machine when I save it to my Word Startup folder. However, when I send the <code>.dotm</code> file to my colleagues (some on same environment as me and some not) an error is generated when pressing the custom ui ribbon button:</p>
  
  <blockquote>
    <p>The macro cannot be found or has been disabled because of your security settings</p>
    
    <p>The macro settings are set to run all macros, the folder containing the template >is a trusted location</p>
    
    <p>.... more help options follow</p>
  </blockquote>
  
  <p>My colleagues also save the file to their startup folder and load Word. The ribbon shows perfectly, but the macro does not run. My colleagues and I have done a boatload of searching online and cannot figure out the issue, as all my configurations are correct, as far as I can tell, which I will list below:</p>
  
  <ul>
  <li>Macro Settings: Enable All Macros</li>
  <li>Trust access to the VBA project object model is checked</li>
  <li>Startup folder is established as a trusted location</li>
  </ul>
  
  <p><strong>Custom UI XML</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui"&gt;
    &lt;ribbon&gt;
      &lt;tabs&gt;
        &lt;tab id="customTab" label="WebMerge"&gt;
          &lt;group id="CustomHelp" label="Map Tags"&gt;
            &lt;button id="mapper"
                    visible="true"
                    size="large"
                    label="Open Mapper"
                    screentip="Opens Mapping Engine"
                    onAction="LoadMappingGuide"
              imageMso="FindDialog"/&gt;
          &lt;/group&gt;
        &lt;/tab&gt;
      &lt;/tabs&gt;
    &lt;/ribbon&gt;
  &lt;/customUI&gt;
  </code></pre>
  
  <p><strong>UI Ribbon Connection in Standard Module</strong></p>
  
  <pre><code>Option Explicit
  
  Sub LoadMappingGuide(ByVal Control As IRibbonControl) 'also tried without ByVal
  
      'select business unit or automatically detect based on username against our database ...
      Dim mappingForm As New mappingGuide
      mappingForm.Show vbModal
  
  End Sub
  </code></pre>
  
  <p><strong>mappingForm (UserForm) Code</strong></p>
  
  <pre><code>Option Explicit
  
  Private Sub cancelButton_Click()
  
      Unload Me
  
  End Sub
  
  Private Sub searchBox_Change()
  
      generateList
  
      Dim n As Long, index As Long
  
      index = 0
  
      For n = 0 To smartTagList.ListCount - 1
          If InStr(1, smartTagList.List(index, 0), searchBox.Value, vbTextCompare) &gt; 0 Then
              index = index + 1
          ElseIf InStr(1, smartTagList.List(index, 1), searchBox.Value, vbTextCompare) &gt; 0 Then
              index = index + 1
          ElseIf InStr(1, smartTagList.List(index, 2), searchBox.Value, vbTextCompare) &gt; 0 Then
              index = index + 1
          Else
              smartTagList.RemoveItem (index)
          End If
      Next n
  
  End Sub
  
  Private Sub smartTagList_Click()
  
      If smartTagList.ListIndex &gt; -1 And smartTagList.Selected(smartTagList.ListIndex) Then
  
          Dim smartyTag As String
          smartyTag = smartTagList.List(smartTagList.ListIndex, 2)
  
          Selection.Range.Text = smartyTag
  
      End If
  
      Unload Me
  
  End Sub
  
  Private Sub UserForm_Initialize()
  
      generateList
  
  End Sub
  
  Private Sub generateList()
  
      'replace with code to get values from database
  
      Dim fields() As String
      Dim descriptions() As String
      Dim smartyTags() As String
  
      fields = Split("Producer Name,Producer Address,Producer City,Producer State,Producer Zip,Insured Name,Insured Address,Insured City,Insured State,Insured ZIp,Risk Premium,TRIA Premium,Final Premium", ",")
      descriptions = Split("Name of Producer,Address Line of Producer,City of Producer,State of Producer,Zip Code of Producer,Name of Insured,Address of Insured,City of Insured,State of Insured,ZIp of Insured,Total Premium for all risks excluding terrorism taxes and surcharges.,Premium resulting from acceptance of terrorism protection,Total Premium of quote / policy", ",")
      smartyTags = Split("{$Producer Name},{$ProducerAddress},{$ProducerCity},{$ProducerState},{$ProducerZip},{$InsuredName},{$InsuredAddress},{$InsuredCity},{$InsuredState},{$InsuredZIp},{$RiskPremium},{$TRIAPremium},{$FinalPremium}", ",")
  
      Dim i As Long
      For i = LBound(fields) To UBound(fields)
  
          With smartTagList
  
              .AddItem
              .List(i, 0) = fields(i)
              .List(i, 1) = descriptions(i)
              .List(i, 2) = smartyTags(i)
  
          End With
  
      Next
  
  End Sub
  </code></pre>
  
  <p>This is what my VBE looks like with <code>.dotm</code> open.</p>
  
  <p><a href="https://i.stack.imgur.com/IOJTs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IOJTs.png" alt="enter image description here"></a></p>