Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 149
Default Loading a Reference

I need to load the "Microsoft ActiveX Data Objects 2.6 Library" when a
particular worksheet opens. I alreafdy plan to create an add-in to hold my
code and special menu.

Can VBA load a reference? Any links to examples?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Loading a Reference

In the VBA editor, go to Tools, References, then add the specific ADO.

Kou
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 149
Default Loading a Reference

I know how to do that, I was asking if it's possible with VBA.


"Kou Vang" wrote in message
...
In the VBA editor, go to Tools, References, then add the specific ADO.

Kou



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Loading a Reference

http://support.microsoft.com/default...b;en-us;160647
XL97: How to Programmatically Create a Reference

applicable to Excel 97 and later.

--
Regards,
Tom Ogilvy


"scott" wrote in message
...
I know how to do that, I was asking if it's possible with VBA.


"Kou Vang" wrote in message
...
In the VBA editor, go to Tools, References, then add the specific ADO.

Kou





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 149
Default Loading a Reference

Hey Tom, I'm just trying to load a Reference Library of ADO 2.6, although
your link was helpful in another way.


"Tom Ogilvy" wrote in message
...
http://support.microsoft.com/default...b;en-us;160647
XL97: How to Programmatically Create a Reference

applicable to Excel 97 and later.

--
Regards,
Tom Ogilvy


"scott" wrote in message
...
I know how to do that, I was asking if it's possible with VBA.


"Kou Vang" wrote in message
...
In the VBA editor, go to Tools, References, then add the specific ADO.

Kou









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 149
Default Loading a Reference

i'm sorry, i think that's going to work. i though your link was just
accessing functions on another sheet.


"Tom Ogilvy" wrote in message
...
http://support.microsoft.com/default...b;en-us;160647
XL97: How to Programmatically Create a Reference

applicable to Excel 97 and later.

--
Regards,
Tom Ogilvy


"scott" wrote in message
...
I know how to do that, I was asking if it's possible with VBA.


"Kou Vang" wrote in message
...
In the VBA editor, go to Tools, References, then add the specific ADO.

Kou







  #7   Report Post  
Posted to microsoft.public.excel.programming
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.

--

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Loading a Reference

Jamie,
You can certainly:
Set obj1 = CreateObject("ADODB.Recordset.2.5")
Set obj2 = CreateObject("ADODB.Recordset.2.7")

That's if you really eanted to

NickHK

"Jamie Collins" wrote in message
oups.com...

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.

--



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 593
Default Loading a Reference


NickHK wrote:

You can certainly:
Set obj1 = CreateObject("ADODB.Recordset.2.5")
Set obj2 = CreateObject("ADODB.Recordset.2.7")


For the recordset object, I have three registry keys:

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ADODB.Recordse t
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ADODB.Recordse t.2.8
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ADODB.Recordse t.2.7

However, they all share the same CLSID, so it doesn't matter which name
I use in CreateObject, I'll always get an object from the same
component.

My machine also has version ADO 2.6 available as a reference, but when
I try

Set obj1 = CreateObject("ADODB.Recordset.2.6")

I get the expected error, 'ActiveX component can't create object'.
Jamie.

--

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
loading add ins [email protected] Excel Discussion (Misc queries) 0 October 30th 08 02:51 PM
Loading... K Excel Discussion (Misc queries) 1 October 7th 07 09:37 PM
loading mallahd Excel Discussion (Misc queries) 2 May 25th 07 07:59 PM
Add-ins not loading John F Excel Discussion (Misc queries) 2 February 17th 05 08:54 PM
Loading Bar rebel1970[_3_] Excel Programming 1 June 22nd 04 10:21 AM


All times are GMT +1. The time now is 10:12 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"