PC Review


Reply
Thread Tools Rate Thread

dll files in Excel VBA or ADO

 
 
=?Utf-8?B?QnJlbnQ=?=
Guest
Posts: n/a
 
      2nd Apr 2007
Can you "#include" a dll file in an Excel routine using VBA or ADO? I am
trying to make a routine that a user can copy and paste, without any other
efforts. Right now they have to select two references for the routine to
work. I can not find the equivalent of #include for VBA/ADO. Thank you.

Brent
 
Reply With Quote
 
 
 
 
Tim Williams
Guest
Posts: n/a
 
      2nd Apr 2007

'Early binding
Dim oRS as New ADODB.Recordset '(the lazy way using New)


vs

'late binding - does not require VBA Project reference to ADO library
Dim oRS as Object
set oRS = CreateObject("ADODB.Recordset")

--
Tim Williams
Palo Alto, CA


"Brent" <(E-Mail Removed)> wrote in message news:5AD2F465-A74E-4205-A058-(E-Mail Removed)...
> Can you "#include" a dll file in an Excel routine using VBA or ADO? I am
> trying to make a routine that a user can copy and paste, without any other
> efforts. Right now they have to select two references for the routine to
> work. I can not find the equivalent of #include for VBA/ADO. Thank you.
>
> Brent



 
Reply With Quote
 
=?Utf-8?B?QnJlbnQ=?=
Guest
Posts: n/a
 
      2nd Apr 2007
Okay I already have it as the lazy way, but I still have to go to
Tools->References and pick A.D.O. 2.8 library. Is there a way that I don't
have to go to Tools->References and do this for each new workbook?

Brent


"Tim Williams" wrote:

>
> 'Early binding
> Dim oRS as New ADODB.Recordset '(the lazy way using New)
>
>
> vs
>
> 'late binding - does not require VBA Project reference to ADO library
> Dim oRS as Object
> set oRS = CreateObject("ADODB.Recordset")
>
> --
> Tim Williams
> Palo Alto, CA
>
>
> "Brent" <(E-Mail Removed)> wrote in message news:5AD2F465-A74E-4205-A058-(E-Mail Removed)...
> > Can you "#include" a dll file in an Excel routine using VBA or ADO? I am
> > trying to make a routine that a user can copy and paste, without any other
> > efforts. Right now they have to select two references for the routine to
> > work. I can not find the equivalent of #include for VBA/ADO. Thank you.
> >
> > Brent

>
>
>

 
Reply With Quote
 
=?Utf-8?B?SmltIFRob21saW5zb24=?=
Guest
Posts: n/a
 
      2nd Apr 2007
You want to use Late Binding as demonstrrated by Tim. Early binding binds the
dll at design time where as Late Binding binds the dll at run time. So use...

'late binding - does not require VBA Project reference to ADO library
Dim oRS as Object
set oRS = CreateObject("ADODB.Recordset")
--
HTH...

Jim Thomlinson


"Brent" wrote:

> Okay I already have it as the lazy way, but I still have to go to
> Tools->References and pick A.D.O. 2.8 library. Is there a way that I don't
> have to go to Tools->References and do this for each new workbook?
>
> Brent
>
>
> "Tim Williams" wrote:
>
> >
> > 'Early binding
> > Dim oRS as New ADODB.Recordset '(the lazy way using New)
> >
> >
> > vs
> >
> > 'late binding - does not require VBA Project reference to ADO library
> > Dim oRS as Object
> > set oRS = CreateObject("ADODB.Recordset")
> >
> > --
> > Tim Williams
> > Palo Alto, CA
> >
> >
> > "Brent" <(E-Mail Removed)> wrote in message news:5AD2F465-A74E-4205-A058-(E-Mail Removed)...
> > > Can you "#include" a dll file in an Excel routine using VBA or ADO? I am
> > > trying to make a routine that a user can copy and paste, without any other
> > > efforts. Right now they have to select two references for the routine to
> > > work. I can not find the equivalent of #include for VBA/ADO. Thank you.
> > >
> > > Brent

> >
> >
> >

 
Reply With Quote
 
=?Utf-8?B?QnJlbnQ=?=
Guest
Posts: n/a
 
      3rd Apr 2007
I am still having to select the library, otherwise the VBA project will not
run and stops at:

rs.Open "table1", cn, adOpenKeyset, adLockOptimistic, adCmdTable


"Jim Thomlinson" wrote:

> You want to use Late Binding as demonstrrated by Tim. Early binding binds the
> dll at design time where as Late Binding binds the dll at run time. So use...
>
> 'late binding - does not require VBA Project reference to ADO library
> Dim oRS as Object
> set oRS = CreateObject("ADODB.Recordset")
> --
> HTH...
>
> Jim Thomlinson
>
>
> "Brent" wrote:
>
> > Okay I already have it as the lazy way, but I still have to go to
> > Tools->References and pick A.D.O. 2.8 library. Is there a way that I don't
> > have to go to Tools->References and do this for each new workbook?
> >
> > Brent
> >
> >
> > "Tim Williams" wrote:
> >
> > >
> > > 'Early binding
> > > Dim oRS as New ADODB.Recordset '(the lazy way using New)
> > >
> > >
> > > vs
> > >
> > > 'late binding - does not require VBA Project reference to ADO library
> > > Dim oRS as Object
> > > set oRS = CreateObject("ADODB.Recordset")
> > >
> > > --
> > > Tim Williams
> > > Palo Alto, CA
> > >
> > >
> > > "Brent" <(E-Mail Removed)> wrote in message news:5AD2F465-A74E-4205-A058-(E-Mail Removed)...
> > > > Can you "#include" a dll file in an Excel routine using VBA or ADO? I am
> > > > trying to make a routine that a user can copy and paste, without any other
> > > > efforts. Right now they have to select two references for the routine to
> > > > work. I can not find the equivalent of #include for VBA/ADO. Thank you.
> > > >
> > > > Brent
> > >
> > >
> > >

 
Reply With Quote
 
Tim Williams
Guest
Posts: n/a
 
      3rd Apr 2007
You'll need to replace those named constans with their actual values. Look them up in the ObjectBrowser (with a reference to ADO
added temporarily)

Eg:
adOpenKeyset = 1
adLockOptimistic = 3
adCmdTable = 2



rs.Open "table1", cn, 1, 3, 2


--
Tim Williams
Palo Alto, CA


"Brent" <(E-Mail Removed)> wrote in message news:1739B67A-C0D1-4CC3-82E2-(E-Mail Removed)...
> I am still having to select the library, otherwise the VBA project will not
> run and stops at:
>
> rs.Open "table1", cn, adOpenKeyset, adLockOptimistic, adCmdTable
>
>
> "Jim Thomlinson" wrote:
>
> > You want to use Late Binding as demonstrrated by Tim. Early binding binds the
> > dll at design time where as Late Binding binds the dll at run time. So use...
> >
> > 'late binding - does not require VBA Project reference to ADO library
> > Dim oRS as Object
> > set oRS = CreateObject("ADODB.Recordset")
> > --
> > HTH...
> >
> > Jim Thomlinson
> >
> >
> > "Brent" wrote:
> >
> > > Okay I already have it as the lazy way, but I still have to go to
> > > Tools->References and pick A.D.O. 2.8 library. Is there a way that I don't
> > > have to go to Tools->References and do this for each new workbook?
> > >
> > > Brent
> > >
> > >
> > > "Tim Williams" wrote:
> > >
> > > >
> > > > 'Early binding
> > > > Dim oRS as New ADODB.Recordset '(the lazy way using New)
> > > >
> > > >
> > > > vs
> > > >
> > > > 'late binding - does not require VBA Project reference to ADO library
> > > > Dim oRS as Object
> > > > set oRS = CreateObject("ADODB.Recordset")
> > > >
> > > > --
> > > > Tim Williams
> > > > Palo Alto, CA
> > > >
> > > >
> > > > "Brent" <(E-Mail Removed)> wrote in message news:5AD2F465-A74E-4205-A058-(E-Mail Removed)...
> > > > > Can you "#include" a dll file in an Excel routine using VBA or ADO? I am
> > > > > trying to make a routine that a user can copy and paste, without any other
> > > > > efforts. Right now they have to select two references for the routine to
> > > > > work. I can not find the equivalent of #include for VBA/ADO. Thank you.
> > > > >
> > > > > Brent
> > > >
> > > >
> > > >



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Transferring Data from Multiple Excel files to single excel files. Sunil Pradhan Microsoft Excel Programming 2 16th Jun 2009 12:48 AM
Excel 2003 crashes loading excel files created Excel 2000 =?Utf-8?B?SmVmZiBMZXdpbiAgQXVzdHJhbGlh?= Microsoft Excel Misc 0 27th Jun 2005 04:20 AM
Why my Excel 2003 don't open excel files by duble click on excel . =?Utf-8?B?VmFseQ==?= Microsoft Excel Crashes 1 20th Jan 2005 03:10 PM
Excel VBA-How to open several delmited files & SaveAs Excel files waveracerr Microsoft Excel Programming 3 6th Feb 2004 04:30 PM
Excel open up with multiple workbooks created by links to other files that were not excel files James Muir Microsoft Excel Misc 0 23rd Sep 2003 02:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:34 PM.