Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programmatically adding a reference to VBE 1

Status
Not open for further replies.

Stretchwickster

Programmer
Apr 30, 2001
1,746
GB
Hi people!

I successfully managed to programmatically add an add-in to excel but now need to add a reference to the VB Editor References programmatically using Excel 97. Is this possible? I cannot seem to find anything about it in the help or online. However, a friend has informed me that you can do this in Access 97 so I would presume there is a way to do this in Excel also.

Your help would be much appreciated!

Clive [infinity]
Ex nihilo, nihil fit (Out of nothing, nothing comes)
 
The code to add a Reference is:

Code:
Sub Add_a_Reference()
 RefPath = "C:\Ref.xls"
 Workbooks.Open RefPath
 Workbooks("Ref.xls").VBProject.Name = "Test"
 ThisWorkbook.VBProject.References.AddFromFile RefPath
End Sub

To take it out :

Code:
Sub Off_Reference
 ThisWorkbook.VBProject.References.Remove _
          ThisWorkbook.VBProject.References("Test")
End Sub

I hope this helps...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top