title: How to add a reference programmatically using VBA
body: <p>I've written a program that runs and messages Skype with information when if finishes. I need to add a reference for <strong><code>Skype4COM.dll</code></strong> in order to send a message through Skype. We have a dozen or so computers on a network and a shared file server (among other things). All of the other computers need to be able to run this program. I was hoping to avoid setting up the reference by hand. I had planned on putting the reference in a shared location, and adding it programmatically when the program ran.</p>
  
  <p>I can't seem to figure out how to add a reference programmatically to Excel 2007 using VBA. I know how to do it manually: Open <strong><code>VBE --&gt; Tools --&gt; References --&gt; browse --_&gt; File Location and Name</code></strong>. But that's not very useful for my purposes. I know there are ways to do it in <a href="https://stackoverflow.com/questions/594239/how-to-add-remove-reference-programmatically">Access Vb.net</a> and code similar to this kept popping up, but I'm not sure I understand it, or if it's relevant: </p>
  
  <pre><code>ThisWorkbook.VBProject.References.AddFromGuid _
      GUID:="{0002E157-0000-0000-C000-000000000046}", _
      Major:=5, Minor:=3
  </code></pre>
  
  <p>So far, in the solutions presented, in order to add the reference programmatically I will need to add a reference by hand and change the Trust Center - which is more than just adding the reference. Though I guess if I follow through with the solutions proposed I will be able to add future references programmatically. Which probably makes it worth the effort.</p>
  
  <p>Any further thoughts would be great.  </p>