Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO Connection locking excel file

Status
Not open for further replies.

DJB10

Programmer
Oct 26, 2009
3
GB
Is there a way to create an ADO connection to an excel spreadsheet but not lock the file for editing?

By setting the .Mode property of the ADODB.Connection object to 'adReadMode' I can allow multiple users to connect to a file in read-only, however the first user to connect will also still lock the file for the editing. If i were to attempt to open up this spreadsheet manually while a user is connected to it, i would be prompted that the file is in use and I can only access the file in read-only.

Is there any way I can get round this, or is it just something that ADO does no matter how i connect?

I am creating my connection with the following code:

Dim cn As New ADODB.Connection

cn.Mode = adModeRead
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & sFilePath & ";" & _
"Extended Properties=""Excel 8.0; HDR=YES;"""

Thanks in advance
 
A shot in the dark: what happens when you open the connection using the adAsyncConnect option?

Cogito eggo sum – I think, therefore I am a waffle.
 
I believe that option determines when you will get a return from the .open method - before or after the connection has completed. I gave it a go though, but the end result is the same.

Thanks anyway
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top