' 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