Libraries in Excel
maybe this will give you some idea... this is for Excel 2003. Create a new
workbook and paste the code in the Thisworkbook code module. Save it and
then open the workbook. It would add a reference to ADO Library 2.8 on open.
One caveat to this is that you must permit access to the Visual Basic
Project. Tools-Macro-Security, in the Trusted Publishers tab, check "Trust
Access to Visual Basic Project".
Option Explicit
Private Sub Workbook_Open()
If Not IsADOReferenced Then
ThisWorkbook.VBProject.References.AddFromGuid
"{2A75196C-D9EB-4129-B803-931327F72D5C}", 2, 8
End If
Test_ADO
End Sub
Private Function IsADOReferenced() As Boolean
Dim strGUID As String
Dim r As Object
strGUID = "{2A75196C-D9EB-4129-B803-931327F72D5C}"
IsADOReferenced = False
For Each r In ThisWorkbook.VBProject.References
If r.GUID = strGUID Then
IsADOReferenced = True
Exit For
End If
Next r
End Function
Private Sub Test_ADO()
Dim conn As New ADODB.Connection
MsgBox conn.Version
End Sub
--
Hope that helps.
Vergel Adriano
"Brent" wrote:
I am trying to bystep making each user go to Tools-References on the toolbar
in the visual basic editor, to check the box to include the ADO 2.8 Library.
Using early and/or late binding seems to do nothing as far as "checking the
box" for the user. Is there coding, since you cannot do macros for this, to
include the library? Like in C++ you would use the statement #include to add
a library, what do you have to do for either VBA or ADO?? Thank you.
Brent
|