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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programatically load reference ActiveX Data Objects x.x Library 1

Status
Not open for further replies.

osx99

Technical User
Apr 9, 2003
250
GB

I have some code which requires reference to the
Microsoft ActiveX Data Objects x.x Library; The one I am using is the'Microsoft ActiveX Data Objects 2.8 Library'

Eventually this code may be used by other people. Is there a way to programatically load the required reference in VBA?

Thanks,
Os
 
As a general thought on this you should be able to use:
Code:
Application.VBE.ActiveVBProject.References.AddFrom...
Hope this helps

Andy
---------------------------------
[green]' Signature removed for testing purposes.[/green]

 
It's in Excel

Can you give me a little bit more help with this one on syntax and where to place

This is the location of the reference I need
C:\Program Files\Common Files\System\ado\msado15.dll

Application.VBE.ActiveVBProject.References.AddFrom ("C:\Program Files\Common Files\System\ado\msado15.dll") doesn't work for me

Should this go in a Workbook_Open Event or is it ok to put in a module?

Thanks,
Os
 
Sorry, the AddFrom... was to indicate there are two choices for the AddFrom (being AddFromFile and AddFromGUID, AddFromFile is what you're after). Try:
Code:
Application.VBE.ActiveVBProject.References.AddFromFile "C:\Program Files\Common Files\System\ado\msado15.dll"
I'd probably put in a module and call it seperately but it will work either way.

Hope this helps

Andy
---------------------------------
[green]' Signature removed for testing purposes.[/green]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top