title: How do I programatically add a reference to a VBA project?
body: <p>I'm deploying an early bound styled VBA module that needs <strong>Scripting.Dictionary</strong> and <strong>RegExp</strong>.</p>
  
  <p>The script, predictably, fails when it runs on another computer. 
  The user has to go to Tools->Reference in the VBA IDE and add a reference to those two libraries manually to make it work.</p>
  
  <p>Hence lies the problem. Asking the non-technical end user to go to the IDE and manually add references is asking way too much of them.</p>
  
  <p>The other alternative is to rewrite the whole (very long script written by someone else) to use late binding. I rather not take this path if there are other methods.</p>
  
  <p>As an altervative, some people suggest adding a reference programatically like so:</p>
  
  <p><code>Application.VBE.ActiveVBProject.References.AddFromFile [Path to library]</code></p>
  
  <ol>
  <li>Is this the correct solution and if so are there any downsides of this strategy?</li>
  <li>If not, are there other methods that will to enable the code to remain early bound yet does not require references to be added manually by the user. </li>
  </ol>
  
  <p>Suggestions involving direct calls to the Win32/64 API are also welcome.</p>
  
  <p>Thanks.</p>