Setting References Pogrammatically

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am creating a small application that I will install on serveral PCs.

However, I would like to avoid having to MANUALLY set the correct references
for every PC as well as PCs.

May someone tell me how I would set MS Access references programmatically.

Thanks for your help
 
elyse,

Unless you are going to make *database design* changes in the
application, I've found it is best to remove all references possible and
use late binding in the distributed database.

The benefits of early binding are really in code creation (Intellisense,
named constants). Early-bound code is supposed to run faster, but
I've never seen an appreciable speed difference.

All that said, you can manipulate the application's References
collection. There are two methods of adding refs, by filename or by GUID.

Application.References.AddFromFile strFullPathToFile

or

Application.References.AddFromGUID strGUID, lngMajorVersion, lngMinorVersion

The definitive information on References is:
http://www.trigeminal.com/usenet/usenet026.asp?1033

HTH,

Kevin
 
Hi Elyse,

I tried this recently to ensure that the Reference for Office 10.0 and ADO
were always present on the machines using the database.

Dim mRef as Reference
Dim officeFound As Boolean
Dim adorFound As Boolean

For Each mRef In CurrentProject.Application.References
If mRef.Name = "Office" Then
officeFound = True
ElseIf mRef.Name = "ADOR" Then
adorFound = True
End If
Next

If Not officeFound Then
Set prProject = References.AddFromFile("C:\Program Files\Microsoft
Office\Office\mso9.dll")
ElseIf Not adorFound Then
Set prProject = References.AddFromFile("C:\Program Files\Common
Files\System\ado\msador15.dll")
End If

This adds them from the default folder they exist in. Obviously if they are
not there then the reference will not be added. In that case you might want
to add the .dll files to a network share and the code could add them from
there.

Hope this helps
Sion
 
Back
Top