Excel instance isolation problem

  • Follow


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 


0
Reply PO 3/9/2010 10:07:12 AM


0 Replies
223 Views

(page loaded in 0.86 seconds)


Reply: