M
Mike O'Brien
Hello Group,
I would like to fix broken references through code. I
have tried a variety of methods, but cannot seem to grab
hold of the broken references to delete / recreate them.
The basic problem is this: I have msadox.dll with version
2.7, and I create a database with VBA within, then install
it on someone's computer who only has ADOX 2.5. The
broken reference won't allow the db to compile / work.
The target computer users won't have the technical
knowledge to use Tools -> References, clear the box, etc,
and I don't know who's computer this will eventually be
installed on (so I can't do it myself).
The code is below, and gets stopped on 'If ((ref.Name
= "VBA") Or (ref.Name = "Access")) Then' because it cannot
determine the property of the Name. Even moving the line
to 'appaccess.References.Remove ref' creates a run-time
error (Num: -2147319779, Desc: Object library not
registered)
Any help would be greatly appreciated.
Thanks.
Mike.
Function RemoveAndSetReferences()
Dim strDB As String
Dim strFile As String
Dim ref As Reference
Dim appAccess As New Access.Application
' REMOVE EXISTING REFERENCES
appAccess.OpenCurrentDatabase "C:\Documents and
Settings\mowalker\My Documents\Databases\CRM.mdb"
For Each ref In appAccess.References
If ((ref.Name = "VBA") Or (ref.Name = "Access"))
Then
Else
appAccess.References.Remove ref
End If
Next ref
' SET UP REFERENCES
' OLE AUTOMATION
appAccess.References.AddFromFile "C:\WINNT\System32
\stdole2.tlb"
' ADODB 2.1
appAccess.References.AddFromFile "C:\Program
Files\Common Files\System\ado\msado21.tlb"
' ADOX 2.5
appAccess.References.AddFromFile "C:\Program
Files\Common Files\System\ado\msadox.dll"
End Function
I would like to fix broken references through code. I
have tried a variety of methods, but cannot seem to grab
hold of the broken references to delete / recreate them.
The basic problem is this: I have msadox.dll with version
2.7, and I create a database with VBA within, then install
it on someone's computer who only has ADOX 2.5. The
broken reference won't allow the db to compile / work.
The target computer users won't have the technical
knowledge to use Tools -> References, clear the box, etc,
and I don't know who's computer this will eventually be
installed on (so I can't do it myself).
The code is below, and gets stopped on 'If ((ref.Name
= "VBA") Or (ref.Name = "Access")) Then' because it cannot
determine the property of the Name. Even moving the line
to 'appaccess.References.Remove ref' creates a run-time
error (Num: -2147319779, Desc: Object library not
registered)
Any help would be greatly appreciated.
Thanks.
Mike.
Function RemoveAndSetReferences()
Dim strDB As String
Dim strFile As String
Dim ref As Reference
Dim appAccess As New Access.Application
' REMOVE EXISTING REFERENCES
appAccess.OpenCurrentDatabase "C:\Documents and
Settings\mowalker\My Documents\Databases\CRM.mdb"
For Each ref In appAccess.References
If ((ref.Name = "VBA") Or (ref.Name = "Access"))
Then
Else
appAccess.References.Remove ref
End If
Next ref
' SET UP REFERENCES
' OLE AUTOMATION
appAccess.References.AddFromFile "C:\WINNT\System32
\stdole2.tlb"
' ADODB 2.1
appAccess.References.AddFromFile "C:\Program
Files\Common Files\System\ado\msado21.tlb"
' ADOX 2.5
appAccess.References.AddFromFile "C:\Program
Files\Common Files\System\ado\msadox.dll"
End Function