title: Call an Excel macro from a different Workbook
body: <p>I have a workbook HasMacros.xlsm and a workbook HasData.xlsm</p>
  
  <p>In HasMacros.xlsm I add a module named Mod1 with this code only:</p>
  
  <pre><code>Sub testmacro()
  
     MsgBox ("Test")
  
  End Sub
  </code></pre>
  
  <p>In HasData.xlsm I add a module named Mod2 with this code only:</p>
  
  <pre><code>Sub testmacro2()
  
     'XXX
  
  End Sub
  </code></pre>
  
  <p>Nothing else opened in Excel.</p>
  
  <p>I want to call testmacro from testmacro2 where XXX is written.</p>
  
  <p>This fails with immediate compilation error:</p>
  
  <pre><code>Sub testmacro2()
  
     testmacro()
  
  End Sub
  </code></pre>
  
  <p>This fails with compilation error "Sub of function not defined" on execute:</p>
  
  <pre><code>Sub testmacro2()
  
     Call testmacro
  
  End Sub
  </code></pre>
  
  <p>This fails with immediate compilation error:</p>
  
  <pre><code>Sub testmacro2()
  
     Mod1.testmacro()
  
  End Sub
  </code></pre>
  
  <p>This fails on execute:</p>
  
  <pre><code>Sub testmacro2()
  
     Call Mod1.testmacro
  
  End Sub
  </code></pre>
  
  <p>I tried <a href="https://stackoverflow.com/questions/10012463/how-to-call-function-from-another-specific-workbook-in-vba">How to call function from another specific workbook in VBA?</a> but I get</p>
  
  <blockquote>
    <p>Name conflicts with existing module, project, or object library</p>
  </blockquote>
  
  <p>How do I call a macro in HasMacros.xlsm from VBA code in HasData.xlsm</p>