ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Pasting ADODB recordset into unopened workbooks (https://www.excelbanter.com/excel-programming/372675-pasting-adodb-recordset-into-unopened-workbooks.html)

JVLin

Pasting ADODB recordset into unopened workbooks
 
Hi,

I'm trying to paste data into a workbook from an ADODB recordset using
..CopyFromRecordset rsData. However, I'd prefer not to open the target
workbook, because this slows things down a lot (when executed on 50+ files).

Is there a way to use .CopyFromRecordset rsData with an unopened workbook?

Or alternatively, is there a way I can set up a connection to the targetfile
and use an "Insert * From" string to refer to a variant array?

In other words, is there a way to: create the ADODB recordset from the
source file, paste the data into thisworkbook and create a vaData from this,
which is then used as "VALUES(vaData)" in the insert connection string? (I've
gotten as far as pasting the data and creating the vaData, but I can't get it
to work in the insert string.)

Many thanks for any tips.

Regards,
JvL


Tom Ogilvy

Pasting ADODB recordset into unopened workbooks
 
why not write it as a .CSV file, then when you open it in Excel, it will be
shown as a workbook (which you can then saveas)



--
Regards,
Tom Ogilvy


"JVLin" wrote in message
...
Hi,

I'm trying to paste data into a workbook from an ADODB recordset using
.CopyFromRecordset rsData. However, I'd prefer not to open the target
workbook, because this slows things down a lot (when executed on 50+
files).

Is there a way to use .CopyFromRecordset rsData with an unopened workbook?

Or alternatively, is there a way I can set up a connection to the
targetfile
and use an "Insert * From" string to refer to a variant array?

In other words, is there a way to: create the ADODB recordset from the
source file, paste the data into thisworkbook and create a vaData from
this,
which is then used as "VALUES(vaData)" in the insert connection string?
(I've
gotten as far as pasting the data and creating the vaData, but I can't get
it
to work in the insert string.)

Many thanks for any tips.

Regards,
JvL




JVLin

Pasting ADODB recordset into unopened workbooks
 
Why don't you answer the question?

"Tom Ogilvy" wrote:

why not write it as a .CSV file, then when you open it in Excel, it will be
shown as a workbook (which you can then saveas)



--
Regards,
Tom Ogilvy


"JVLin" wrote in message
...
Hi,

I'm trying to paste data into a workbook from an ADODB recordset using
.CopyFromRecordset rsData. However, I'd prefer not to open the target
workbook, because this slows things down a lot (when executed on 50+
files).

Is there a way to use .CopyFromRecordset rsData with an unopened workbook?

Or alternatively, is there a way I can set up a connection to the
targetfile
and use an "Insert * From" string to refer to a variant array?

In other words, is there a way to: create the ADODB recordset from the
source file, paste the data into thisworkbook and create a vaData from
this,
which is then used as "VALUES(vaData)" in the insert connection string?
(I've
gotten as far as pasting the data and creating the vaData, but I can't get
it
to work in the insert string.)

Many thanks for any tips.

Regards,
JvL





Tom Ogilvy

Pasting ADODB recordset into unopened workbooks
 
Without knowing what you are doing, it was an honest suggestion. Maybe you
will like these better.

http://support.microsoft.com/kb/295646/en-us
How To Transfer Data from ADO Data Source to Excel with ADO

http://support.microsoft.com/kb/247412/en-us
Methods for transferring data to Excel from Visual Basic

http://support.microsoft.com/kb/257819/en-us
How To Use ADO with Excel Data from Visual Basic or VBA


--
Regards,
Tom Ogilvy


"JVLin" wrote in message
...
Why don't you answer the question?

"Tom Ogilvy" wrote:

why not write it as a .CSV file, then when you open it in Excel, it will
be
shown as a workbook (which you can then saveas)



--
Regards,
Tom Ogilvy


"JVLin" wrote in message
...
Hi,

I'm trying to paste data into a workbook from an ADODB recordset using
.CopyFromRecordset rsData. However, I'd prefer not to open the target
workbook, because this slows things down a lot (when executed on 50+
files).

Is there a way to use .CopyFromRecordset rsData with an unopened
workbook?

Or alternatively, is there a way I can set up a connection to the
targetfile
and use an "Insert * From" string to refer to a variant array?

In other words, is there a way to: create the ADODB recordset from the
source file, paste the data into thisworkbook and create a vaData from
this,
which is then used as "VALUES(vaData)" in the insert connection string?
(I've
gotten as far as pasting the data and creating the vaData, but I can't
get
it
to work in the insert string.)

Many thanks for any tips.

Regards,
JvL








All times are GMT +1. The time now is 09:14 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com