LockXLS On-line Help Library

no items
folder
folder
folder
folder
no items
no items
no items

Open locked document from external application using OLEDB/ODBC driver.

Excel File Compiler Screenshot

You can open locked file using OLEDB and ODBC. You should use same code as you are using for usual Excel workbook. But, it must be placed between the following statements:

' declare variable for LockXLS Runtime object
Dim oLockXLS As Object
' get Runtime Object from Excel application
Set oLockXLS = CreateObject( "LockXLSRuntime.Connect" );
' enable access for ODBC driver
Call oLockXLS.EnableODBCAccess( True )
' open locked workbook using OLEDB/ODBC
Dim oConnection As ADODB.Connection
Dim oRS As ADODB.Recordset

Set oConnection = New ADODB.Connection

oConnection.Provider = "Microsoft.Jet.OLEDB.4.0"
oConnection.ConnectionString = _
  "Data Source=" & ActiveDocument.Path & "\Source.xls;" & _
  "Extended Properties=Excel 8.0;"

oConnection.Open

Set oRS = New ADODB.Recordset

oRS.Open "Select * from [Sheet1$]", oConnection

While Not oRS.EOF
  ...
  oRS.MoveNext
Wend

oRS.Close
oConnection.Close

' disable access for ODBC driver this call is required
Call oLockXLS.EnableODBCAccess( False )
' release LockXLS Runtime object
Set oLockXLS = Nothing

See Also:
LockXLS Runtime Object members