473,769 Members | 4,173 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5714
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 TransferSpreads heet

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 - programmaticall y.
The TransferSpreads heet 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 - programmaticall y.
Well, if the spreadsheet is linked, it's like a table. But I'm missing
the point from what you say.
The TransferSpreads heet 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
6488
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 wizard..... If I have to write vb code, where is a sample??? Or do I import the excel in to a new spreadsheet and then write some kind of querey to move the data from that table
1
2482
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. Each column is named to agree with the Access database. Read the instructions "Import Excel files into an Access database". Followed them to the letter. Everything goes well until the final Wizard action is clicked "Import to table 'PHONEDIR'.
2
2276
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. Does anyody have access code to open an exel sheet and read it into a table in access in code? 2. have the user maintain an autonumber like field. THis way, I can have this to sort on when I import it. Does excel have an autonumber field?
0
4200
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 Excel 2003, I have VBA code that creates and executes queries using the Access database, and returns the results to an Excel sheet. The first time the query is executed, results are returned to Excel in usually less than 10 seconds. However, if the...
4
4532
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 tab delimited file or an excel file. The application then saves the file in the correct format. The flip side is for the user to import/upload the file to the server The application must be able to import the excel file and read the contents. I...
8
3165
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 data to it, then moves on to the next rep: ---------- conTARGETVisits = FTPLocation & "RepCallPlan" & Format(MyRepCode, "00")
0
2758
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 Excel Application that I create, but when I open a Workbook in the Application I can't successfully Quit Excel (by this I mean I can quit it, but the Excel process isn't getting killed and I have to manually go this through Task Manager). I've...
1
8710
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 6.0. Code: --- use in mainform ------- Option Compare Database Option Explicit
1
4563
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: ThisFile2007-02-01 11.02.00.421.xls Is there a way a can create some sort of link that matches a pattern? If file name starts with 'ThisFile'
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10211
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5299
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3959
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.