title: How to import VBScript macros into Excel workbook?
body: <p>I have several Excel workbooks. They all share the same macro modules. What I would like to achieve is when editing one module in one workbook not to have to edit the same module in the other workbooks.</p>
  
  <p>Naturally, my first step was to export on save the modules in .bas files. But the problem is that I cannot import them on load.</p>
  
  <p>I had tried this:</p>
  
  <pre><code>Private Sub Workbook_Open()
      Set objwb = ThisWorkbook
      Set oVBC = objwb.VBProject.VBComponents
      Set CM = oVBC.Import("C:\Temp\TestModule.bas")
      TestFunc
  End Sub
  </code></pre>
  
  <p>There is a TestModule.bas in the same dir with content:</p>
  
  <pre><code>Function TestFunc()
      MsgBox "TestFunc called"
  End Function
  </code></pre>
  
  <p>When the workbook is opened, a compile error appears: <code>Sub or Function not defined</code>. If I manually import the module everything works just fine.</p>
  
  <p>Thanks for any advice.</p>