ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel instance isolation problem (https://www.excelbanter.com/excel-programming/440413-excel-instance-isolation-problem.html)

PO

Excel instance isolation problem
 
Excel 2003, sp2


Hi,

I'm using an add-in to create a report. The report is put together with data
from a few named ranges in a hidden excel worksheet. Below is the relevant
code that's in a standard module in the add-in.


Dim wkbData As Excel.Workbook
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset

Dim sFileConnectionString As String
Dim sFilePath As String

Set wkbData = ActiveWorkbook

sFilePath = wkbData.FullName

sFileConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & sFilePath & ";Extended Properties=""Excel
8.0;HDR=Yes"";"

Set cn = New ADODB.Connection
cn.Open (sFileConnectionString)

Set rs = New ADODB.Recordset

... more code to generate report



Everything works fine as long as I use 1 instance of Excel. As soon as I
have two instances (each with a copy of the data workbook) "cn.Open
(sFileConnectionString)" opens a copy of sFilePath in the 2nd instance in
read-only mode. After that the code starts to mix the data from the two
workbooks.
Isn't each Excel instance isolated from all other instances?

Any ideas?
Pete




All times are GMT +1. The time now is 06:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com