Jake, if you run this function in Excel while another Excel is open it will
create Read-Only instance. As you can see there is nothing here that starts
a new instance of Excel. I am using MDAC 2.8
Private Function Create_CN() As Boolean
Dim xlPath As String
On Error GoTo Err_Handler
Create_CN = False
'-- open XL connection
Set gxlCN = New ADODB.Connection
xlPath = ActiveWorkbook.Path & "\" & ActiveWorkbook.Name
'Stop
With gxlCN
.Provider = "Microsoft.Jet.OLEDB.4.0;"
.ConnectionString = "Data Source=" & xlPath & ";" & _
"Extended Properties=Excel 8.0;"
.CursorLocation = adUseClient
.Open
End With
Create_CN = True
Exit Function
Err_Handler:
Create_CN = False
MsgBox Err.Description, vbCritical, "Error while creating connection..."
'Call Close_CN
End Function
"Jake Marx" wrote in message
...
Hi Serge,
Reading data from an Excel workbook via ADO should not create a new
instance
of Excel. Is there anything else in your code that starts a new Excel
application? Maybe I misunderstood your post....
--
Regards,
Jake Marx
MS MVP - Excel
Serge L wrote:
ok here is my code from example on microsoft website
( http://support.microsoft.com/default.aspx?scid=kb;EN-
US;Q321686 )
With gxlCN
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=" & xlPath & ";" & _
"Extended Properties=""Excel 8.0; HDR=Yes;"" "
.Open
End With
PROBLEM SCENARIO:
2 separate Excel applications are open
1 create connection in one Excel instance -
Connection's creates fine, but the second instance of
Excel now has read-only-instance of first excel app. If I
finish running the code and close both Excel apps, Task
Manager shows instance of Excel running in the memory.
I terminate my connection object like this
If gxlCN Is Nothing = False Then
If gxlCN.State = adStateOpen Then gxlCN.Close
Set gxlCN = Nothing
End If
Please help me open Excel ADO connection without this read-
only copy.
Thank you
Serge