473,385 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Using ADO to import Excel into Access Read Only - while file is open

Here's what I've got: I'm trying to grab some data out of an Excel
spreadsheet and bring it into Access. I'm able to do it, but only if
the Excel spreadsheet is not opened by any other users. I am
connecting to the spreadsheet via ADO (Jet OLE 4.0 Provider). If the
file is opened for editing by another user, I receive the "The
Microsoft Jet database engine cannot open the file ". It is already
opened exclusively by another user, or you need permission to view its
data.
This spreadsheet is used by many people in the work group, so it is
very possible that it will be opened at any given time - I'd like to
still be able to grab data out of it "Read-Only"... Is it possible to
do this with ADO? Is there an "Extended Properties" parameter that
must be set, or maybe a different addition to the connection string?
Any help would be greatly appreciated! Thanks!
-Terry

Feb 3 '06 #1
6 5696
Syvman wrote:
Here's what I've got: I'm trying to grab some data out of an Excel
spreadsheet and bring it into Access. I'm able to do it, but only if
the Excel spreadsheet is not opened by any other users. I am
connecting to the spreadsheet via ADO (Jet OLE 4.0 Provider). If the
file is opened for editing by another user, I receive the "The
Microsoft Jet database engine cannot open the file ". It is already
opened exclusively by another user, or you need permission to view its
data.
This spreadsheet is used by many people in the work group, so it is
very possible that it will be opened at any given time - I'd like to
still be able to grab data out of it "Read-Only"... Is it possible to
do this with ADO? Is there an "Extended Properties" parameter that
must be set, or maybe a different addition to the connection string?
Any help would be greatly appreciated! Thanks!
-Terry

Could you, or I might say, can you link that spreadsheet to your Access
Database? File/GetExternalData/Link? See also TransferSpreadsheet

Feb 3 '06 #2
Well, linking the spreadsheet isn't really an option for me, because I
have to extract the data at a given point - programmatically.
The TransferSpreadsheet method only works if I use automation to open
the spreadsheet first. I cannot do this, because there is a chance
that the user will have that same spreadsheet open on his/her desktop
(Excel cannot open the same file on one machine). I'm starting to
think that what I'm trying to do is not possible, if ADO cannot pull
data from the spreadsheet while it's opened exclusively by a different
user. Thanks for the reply, salad!

Feb 3 '06 #3
Syvman wrote:
Well, linking the spreadsheet isn't really an option for me, because I
have to extract the data at a given point - programmatically.
Well, if the spreadsheet is linked, it's like a table. But I'm missing
the point from what you say.
The TransferSpreadsheet method only works if I use automation to open
the spreadsheet first. I cannot do this, because there is a chance
that the user will have that same spreadsheet open on his/her desktop
(Excel cannot open the same file on one machine). I'm starting to
think that what I'm trying to do is not possible, if ADO cannot pull
data from the spreadsheet while it's opened exclusively by a different
user. Thanks for the reply, salad!

How about this. Do a FileCopy of the spreadsheet. Now I'm not sure if
"new" data will be captured during a filecopy. I doubt it...you'd
probably get the data from the last time the sheet was saved/closed.
Anyway, if you can live with that, filecopying it to another file and
then processing the new one should work. How's that? It's a kludge,
it's a possibility...

See
Dir
Kill
FileCopy
in help for using this concept.

Feb 3 '06 #4
I think you're on to something here - looks like I need to find out now
if I can copy the file while it's already open. If that's possible,
then I'll do a file copy to a temp directory so the user can import
that data.
What I meant by not being able to link to the spreadsheet is that I am
only needing portions of the spreadsheet (namely only one column -
starting at row 4). By linking the spreadsheet as a table, I could get
the data, but I am not sure how to make sure that I ignore the top 3
rows in the spreadsheet (they just become records in the linked table).
That's why I don't think I can use a linked table. However, I am
going to play with this over the weekend also.
Thanks for your help, salad - and if you think of any other possible
solutions, please don't hesitate to let me know - I really appreciate
the help! Thanks again, and have a great weekend!

Feb 3 '06 #5
Oh, also - another reason linking wouldn't work for me is because there
are about 12 "worksheets" within the spreadsheet file, and this would
require 12 linked tables. No big deal, but another worksheet can be
added anytime, and I need to be able to determine how many worksheets
are within the spreadsheet at run-time and ensure that I import the
data from all of them. That's why I thought ADO would be the best
approach, because you can use the OpenSchema property to get the list
of worksheets out of an excel sheet. BUT - the first approach you
suggested (copying the file so the user can have the same file open
simultaneously) would probably work with automation - as long as I can
copy the file while it's already open. I'm going to go test that now.
Thanks again!

Feb 3 '06 #6
Syvman wrote:
Oh, also - another reason linking wouldn't work for me is because there
are about 12 "worksheets" within the spreadsheet file, and this would
require 12 linked tables. No big deal, but another worksheet can be
added anytime, and I need to be able to determine how many worksheets
are within the spreadsheet at run-time and ensure that I import the
data from all of them. That's why I thought ADO would be the best
approach, because you can use the OpenSchema property to get the list
of worksheets out of an excel sheet. BUT - the first approach you
suggested (copying the file so the user can have the same file open
simultaneously) would probably work with automation - as long as I can
copy the file while it's already open. I'm going to go test that now.
Thanks again!

OK. I guess I'm getting hung up on the word ADO. What about VBA? If
you can use automation then perhaps you can work it out. Go to
http://groups.google.com/advanced_search?hl=en
and enter phrases like
Excel object
and in the groups enter
*access*

There's another reference site you might want to visit.
http://www.mvps.org
On the right hand side there's a frame. Scroll down and see Excel links.

Of course, if you can't use VBA then above is useless.

Feb 4 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Fred | last post by:
Hi. How do I import while mapping an excel table to an access table please??? I've searched around and all I can find is a software product or code that does the same thing as the access...
1
by: John Hewitt | last post by:
A 'newbie' question - importing into Access from Excel. Googled the group postings but I can't find the amswer I have a 50 line three column file in Excel that contains Names and Tel numbers....
2
by: Danny | last post by:
I was trying to tihnk of solutions to the table in access being out of order when i use: DoCmd.TransferSpreadsheet in code to import an excel file. 1. I could read the excel file from access....
0
by: Mike Knight | last post by:
(I've also posted this problem on microsoft.public.excel.programming) I have a MS Access 2003 Database named "AS400 Fields.mdb". This database contains links to tables on an AS400. In MS...
4
by: Jae | last post by:
I'm writing a web application that exports and imports excel files. The application gets a list of users and their info and displays it in a datagrid .The user then selects to save the file as a...
8
by: J-P-W | last post by:
Hi, anyone got any thoughts on this problem? I have sales reps. that remotely send their data to an ftp server. The office downloads all files, the code creates an empty file, then downloads the...
0
by: liam_jones | last post by:
I'm very new to Python, well IronPython to precise, and have been having problems when using Excel. The problem I'm having is the closing of my Excel object. I'm able to successfully quit the...
1
by: baling | last post by:
Hi.... Hi everybody, i have a code that i make in VBA and know I want to use this code in to VB6. But i don't know how to use that code in to VB 6.0 Please correct this code so i can use it in VB...
1
by: Steve | last post by:
Hi All, I have an Excel file being delivered to a shared drive where I only have read access on a daily basis. The files arrive in the following format 'Filename+timestamp.xls' Example:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.