View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Jamie Collins Jamie Collins is offline
external usenet poster
 
Posts: 593
Default Loading a Reference


scott wrote:
I need to load the "Microsoft ActiveX Data Objects 2.6 Library" when

a
particular worksheet opens.


Must it be ADO 2.6? Are you sure all your users have this version e.g.
what do you want to happen if they only have ADO 2.8? Rather than
setting a reference (early binding), you may be able to use late
binding e.g. instead of:

Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset

you could use:

Dim rs As Object
On Error Resume Next
Set rs = CreateObject("ADODB.Recordset")
If rs Is Nothing Then
MsgBox "ADO may not be installed."
....

AFAIK You cannot use CreateObject to specify a version; if a machine
has multiple versions, as does mine, you just get the most recently
installed version. With MDAC you can be assured the most recently
installed will have the highest version number.

If it must be ADO 2.6, you may want to check the registry for the
component's progid before attempting to set the reference.
Jamie.

--