title: How to add Microsoft ActiveX Data Objects 6.1 Library and Microsoft VBScript Regular Expressions 5.5 using macro code
body: <p>I always added references into my .bas module through "Tools...->References...". And now I want to add references automatically, using macro code. I need to add the two references: <code>Microsoft ActiveX Data Objects 6.1 Library</code> and <code>Microsoft VBScript Regular Expressions 5.5</code>. And I found a piece of code that seems to do what I want:</p>
  
  <pre><code>Sub ListReferences()
      On Error GoTo CanNotAddReferences
      Application.VBE.ActiveVBProject.References.AddFromFile "PATH_TO_FILE"
      Exit Sub
  CanNotAddReferences:
      MsgBox "Can not add reference"
  End Sub
  </code></pre>
  
  <p>But I don't know how to get paths of files (<code>PATH_TO_FILE</code>). Maybe somebody can help me? Thanks in advance.</p>