Dirk said:
That's what I'm finding. It looks to me like the Jet IISAM for Excel
places a lock on the file. I've tried various things to get around
that, with no success
I suppose as an administrator I may have the Query object open
exclusively but this should not be happen in an application.
I assume the OP only wants read access to the Excel workbook. Updates
to an Excel source via a linked table is not recommended. I think such
a link is opened in 'import mode', equivalent to IMEX=1 in the
connection string, to ensure the registry settings are honored and the
data types are seen as expected (for more details see
http://www.dicks-blog.com/archives/2004/06/03/external-data-mixed-data-types/).
Updating in 'import mode' is not recommended due to 'unpredictable
results'. I've also read in these ngs that such updates can cause
corruption in the mdb.
Rather, the five applications should only be connected to the workbook
long enough to fetch the records e.g. the equivalent of this:
Sub jmctest()
Dim Con As ADODB.Connection
Dim rs(4) As ADODB.Recordset
Dim lngCounter As Long
Set Con = New ADODB.Connection
With Con
.CursorLocation = adUseClient ' client-side cursor
.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Extended Properties='Excel 8.0;HDR=Yes;IMEX=1';" & _
"Data Source=C:\Tempo\db.xls"
.Open
' Create five disconnected recordsets
For lngCounter = 0 To 4
Set rs(lngCounter) = .Execute( _
"SELECT key_col, data_col FROM [Sheet1$]")
rs(lngCounter).ActiveConnection = Nothing ' <<< disconnect
Next
.Close
End With
' Use recordsets e.g.
For lngCounter = 0 To 4
Debug.Print rs(lngCounter).GetString
Next
End Sub
Jamie.
--