LISTING 1. Example Procedure to Add the ADODB Library
Sub ReferenceADODB()
Dim ref1 As Reference
Dim blnADODBIn As Boolean, ADODBLibrary As String
'Enumerate members of References collection to determine
'whether Office Object Libary is already referenced.
blnADODBIn = False
For Each ref1 In References
If ref1.Name = "ADODB" Then
blnADODBIn = True
End If
Next ref1
'If Office Object Library reference is missing reference it.
If blnADODBIn = False Then
ADODBLibrary = _
"C:\Program Files\Common Files\System\ADO\" & _
"msado15.dll"
Application.References.AddFromFile ADODBLibrary
End If
End Sub