Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
AL AL is offline
external usenet poster
 
Posts: 37
Default Update Closed Workbook w/ ADO

I've been retrieving ACCESS data using ADO and I'm
wondering if theres a way to insert that Data into a
closed workbook. Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 459
Default Update Closed Workbook w/ ADO

Absolutely, as long as the workbook is not protected.

The approach is virtually the same. You use the MS OLEDB provider for
Jet but specify Excel in the extended properties e.g.

strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\db.xls;" & _
"ExtendedProperties='Excel 8.0'"

Data must be laid out in database style i.e. rows of columns. Column
headers make things easier (especially one row one column tables). The
Excel equivalent of a table is either a worksheet (suffix with $):

SELECT MyCol FROM [Sheet1$]

a defined Name (no $):

SELECT MyKeyCol FROM [MyRange]

or even a range defined at the worksheet level

SELECT MyKeyCol FROM [Sheet1$MyRange]
- or -
SELECT MyDataCol FROM [Sheet2$D4:D99]


The square brackets are required for an existing 'table'.

Jet proprietary SQL is used but certain functionality is not supported
e.g. DELETE FROM, ALTER TABLE. Inserted rows are appended to the
bottom of a range. And you can't UPDATE a cell which contains a
formula.

--

"AL" wrote in message ...
I've been retrieving ACCESS data using ADO and I'm
wondering if theres a way to insert that Data into a
closed workbook. Thanks in advance.

  #3   Report Post  
Posted to microsoft.public.excel.programming
AL AL is offline
external usenet poster
 
Posts: 37
Default Update Closed Workbook w/ ADO

Thanks for your response. Its is very much appreciated.
I'm almost there. What I now need to now is how do I
WRITE the resultant recordset to the closed workbook?
Lets call the recordset i Have rs, and lets call
the closed workbook, newbook.



-----Original Message-----
Absolutely, as long as the workbook is not protected.

The approach is virtually the same. You use the MS OLEDB

provider for
Jet but specify Excel in the extended properties e.g.

strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\db.xls;" & _
"ExtendedProperties='Excel 8.0'"

Data must be laid out in database style i.e. rows of

columns. Column
headers make things easier (especially one row one column

tables). The
Excel equivalent of a table is either a worksheet (suffix

with $):

SELECT MyCol FROM [Sheet1$]

a defined Name (no $):

SELECT MyKeyCol FROM [MyRange]

or even a range defined at the worksheet level

SELECT MyKeyCol FROM [Sheet1$MyRange]
- or -
SELECT MyDataCol FROM [Sheet2$D4:D99]


The square brackets are required for an existing 'table'.

Jet proprietary SQL is used but certain functionality is

not supported
e.g. DELETE FROM, ALTER TABLE. Inserted rows are appended

to the
bottom of a range. And you can't UPDATE a cell which

contains a
formula.

--

"AL" wrote in

message ...
I've been retrieving ACCESS data using ADO and I'm
wondering if theres a way to insert that Data into a
closed workbook. Thanks in advance.

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Update Closed Workbook w/ ADO

Take a look at the SQL.REQUEST function.

You can run an UPDATE query that will update closed Excel workbooks.

I am working on an example file. In the meantime this file might be a help
for other aspects of SQL.REQUEST:
http://www.bygsoftware.com/examples/...SqlRequest.zip
It's in the "Excel with Access Databases" section on page:
http://www.bygsoftware.com/examples/examples.htm

This workbook demonstrates how to get data direct from an MS Access table,
or from an open or closed MS Excel workbook using the workbook function
SQL.REQUEST.

Recently updated to show the use of SQL.REQUEST in the same workbook.

The code is open and commented.


--
Regards
Andy Wiggins
www.BygSoftware.com
Home of "Save and BackUp",
"The Excel Auditor" and "Byg Tools for VBA"



"Al" wrote in message
...
Thanks for your response. Its is very much appreciated.
I'm almost there. What I now need to now is how do I
WRITE the resultant recordset to the closed workbook?
Lets call the recordset i Have rs, and lets call
the closed workbook, newbook.



-----Original Message-----
Absolutely, as long as the workbook is not protected.

The approach is virtually the same. You use the MS OLEDB

provider for
Jet but specify Excel in the extended properties e.g.

strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\db.xls;" & _
"ExtendedProperties='Excel 8.0'"

Data must be laid out in database style i.e. rows of

columns. Column
headers make things easier (especially one row one column

tables). The
Excel equivalent of a table is either a worksheet (suffix

with $):

SELECT MyCol FROM [Sheet1$]

a defined Name (no $):

SELECT MyKeyCol FROM [MyRange]

or even a range defined at the worksheet level

SELECT MyKeyCol FROM [Sheet1$MyRange]
- or -
SELECT MyDataCol FROM [Sheet2$D4:D99]


The square brackets are required for an existing 'table'.

Jet proprietary SQL is used but certain functionality is

not supported
e.g. DELETE FROM, ALTER TABLE. Inserted rows are appended

to the
bottom of a range. And you can't UPDATE a cell which

contains a
formula.

--

"AL" wrote in

message ...
I've been retrieving ACCESS data using ADO and I'm
wondering if theres a way to insert that Data into a
closed workbook. Thanks in advance.

.



  #5   Report Post  
Posted to microsoft.public.excel.programming
AL AL is offline
external usenet poster
 
Posts: 37
Default Update Closed Workbook w/ ADO

Thanks Andy!! SQL.REQUEST did the trick!
-----Original Message-----
Take a look at the SQL.REQUEST function.

You can run an UPDATE query that will update closed

Excel workbooks.

I am working on an example file. In the meantime this

file might be a help
for other aspects of SQL.REQUEST:
http://www.bygsoftware.com/examples/...s/UsingSqlRequ

est.zip
It's in the "Excel with Access Databases" section on

page:
http://www.bygsoftware.com/examples/examples.htm

This workbook demonstrates how to get data direct from

an MS Access table,
or from an open or closed MS Excel workbook using the

workbook function
SQL.REQUEST.

Recently updated to show the use of SQL.REQUEST in the

same workbook.

The code is open and commented.


--
Regards
Andy Wiggins
www.BygSoftware.com
Home of "Save and BackUp",
"The Excel Auditor" and "Byg Tools for VBA"



"Al" wrote in

message
...
Thanks for your response. Its is very much

appreciated.
I'm almost there. What I now need to now is how do I
WRITE the resultant recordset to the closed workbook?
Lets call the recordset i Have rs, and lets call
the closed workbook, newbook.



-----Original Message-----
Absolutely, as long as the workbook is not protected.

The approach is virtually the same. You use the MS

OLEDB
provider for
Jet but specify Excel in the extended properties e.g.

strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;"

& _
"Data Source=C:\db.xls;" & _
"ExtendedProperties='Excel 8.0'"

Data must be laid out in database style i.e. rows of

columns. Column
headers make things easier (especially one row one

column
tables). The
Excel equivalent of a table is either a worksheet

(suffix
with $):

SELECT MyCol FROM [Sheet1$]

a defined Name (no $):

SELECT MyKeyCol FROM [MyRange]

or even a range defined at the worksheet level

SELECT MyKeyCol FROM [Sheet1$MyRange]
- or -
SELECT MyDataCol FROM [Sheet2$D4:D99]


The square brackets are required for an

existing 'table'.

Jet proprietary SQL is used but certain functionality

is
not supported
e.g. DELETE FROM, ALTER TABLE. Inserted rows are

appended
to the
bottom of a range. And you can't UPDATE a cell which

contains a
formula.

--

"AL" wrote in

message news:<d0b301c3ef6d$1a951f00

...
I've been retrieving ACCESS data using ADO and I'm
wondering if theres a way to insert that Data into a
closed workbook. Thanks in advance.
.



.

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
Links won't update if file is closed cyclop Excel Worksheet Functions 0 May 8th 09 10:18 PM
Update DDE data from closed files ORLANDO V[_2_] Excel Discussion (Misc queries) 0 December 13th 07 09:59 PM
How to update destination file with source files closed? Alex Costache Excel Discussion (Misc queries) 2 August 1st 06 10:08 AM
update a closed file via links Rob Robbins Excel Discussion (Misc queries) 2 July 13th 05 09:25 PM
copy worksheet from closed workbook to active workbook using vba mango Excel Worksheet Functions 6 December 9th 04 07:55 AM


All times are GMT +1. The time now is 10:15 PM.

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

About Us

"It's about Microsoft Excel"