onedaywhen said:
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
I've tried a variety of things, and can't get a lasting, non-exclusive
link to the spreadsheet. I won't say that I;'ve given up, but my time
to work on the problem is limited. If read-only access to the
spreadsheet is all that's required, it seems to me that the easiest
thing to do is just import the data into a local table.
TransferSpreadsheet could be used for that, executed either on a daily
basis, or whenever the database is opened, or by checking the workbook's
last-modified date to see if it's been changed since the last time the
table was imported. With a local table containing the data, a lot of
things become easy.