Excel instance isolation problem

P

PO

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top