Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Use ADO to transfer data from open excel file to closed excel file

I have and open Excel file (Open.xls) that I would like to place a button on
that would place data from a cell on the open sheet into a cell on a closed
sheet (Closed.xls) I would also like to check for certain cells' values in
the open sheet and place certain text in the closed sheet based on this.

Here the naive code I have been trying to do this with. It could be all
wrong, I'm a novice:

Sub BodyOrder()
Dim cn As ADODB.Connection, rs As ADODB.Recordset
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=J:\My
Documents\APS Bodies and Options\Pacific-APS Order Sheet.xls;" & "Extended
Properties=""Excel 8.0;"""
' open a recordset
Set rs = New ADODB.Recordset
rs.Open "SELECT * FROM [Sheet1]"
With rs
.Fields("A2") = Range("D2")
If Range("D3") = 2 Then
.Fields("B2") = "Chevy"
Else
.Fields("B2") = "Ford"
End If

rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Use ADO to transfer data from open excel file to closed excel file


see
http://support.microsoft.com/default...b;en-us;319998

BUG: Memory leak occurs when you query an open Excel worksheet by using
ActiveX Data Objects (ADO)




--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


JCanyoneer wrote :

I have and open Excel file (Open.xls) that I would like to place a
button on that would place data from a cell on the open sheet into a
cell on a closed sheet (Closed.xls) I would also like to check for
certain cells' values in the open sheet and place certain text in the
closed sheet based on this.

Here the naive code I have been trying to do this with. It could be
all wrong, I'm a novice:

Sub BodyOrder()
Dim cn As ADODB.Connection, rs As ADODB.Recordset
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=J:\My
Documents\APS Bodies and Options\Pacific-APS Order Sheet.xls;" &
"Extended Properties=""Excel 8.0;"""
' open a recordset
Set rs = New ADODB.Recordset
rs.Open "SELECT * FROM [Sheet1]"
With rs
.Fields("A2") = Range("D2")
If Range("D3") = 2 Then
.Fields("B2") = "Chevy"
Else
.Fields("B2") = "Ford"
End If

rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub

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
Move entire row of data from open to closed file by entering date TB[_2_] Excel Discussion (Misc queries) 0 May 12th 08 10:07 PM
Is transfer data from one Excel file to another possible? EA Excel Discussion (Misc queries) 2 October 19th 07 04:01 PM
VBA - on a button event, open another closed file, post changes, close file Fio Excel Programming 0 March 1st 04 01:08 PM
Need FASTEST way to get data from a large closed Excel File Dave B[_5_] Excel Programming 13 October 29th 03 09:26 PM
Open delimited text file to excel without changing data in that file zohanc Excel Programming 1 October 3rd 03 01:06 AM


All times are GMT +1. The time now is 03:39 PM.

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"