Instances of Excel don't release

R

Richard Choate

I'm going bananas! My Access code sets up a new instance of Excel and a new
ADO connection via the following code, after I dim the variables:

Set cnt = New ADODB.Connection
Set rst = New ADODB.Recordset

cnt.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strDB & ";" & "Jet OLEDB:Database Password=XXXXX"

' Open recordset based on Orders table
rst.Open mySQL, cnt

Set xlApp = CreateObject("Excel.Application")
Set xlWb = xlApp.workbooks.Open("G:\Path\Path2\Path3\ExcelFile.xls")
Set xlWs = xlWb.Worksheets("Data")

Then, I have code to transfer data and massage it a little bit, and then I
close my references with this:

rst.Close
cnt.Close
Set rst = Nothing
Set cnt = Nothing

' Release Excel references
Set xlWs = Nothing
Set xlWb = Nothing
Set xlApp = Nothing

But then, when I try to open those excel files to see if everything looks
OK, they are locked for editing and the instances of Excel are still open. I
end up having to use the task manager to shut them down. Where did I go
wrong ???

Richard Choate
 
R

Richard Choate

Please forgive me ! My newsreader freaked out and sent my post twice after
giving me ridiculous error messages. I'm going to re-post this issue under a
new post with a new subject line so it will be less confusing.
Richard

I'm going bananas! My Access code sets up a new instance of Excel and a new
ADO connection via the following code, after I dim the variables:

Set cnt = New ADODB.Connection
Set rst = New ADODB.Recordset

cnt.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strDB & ";" & "Jet OLEDB:Database Password=XXXXX"

' Open recordset based on Orders table
rst.Open mySQL, cnt

Set xlApp = CreateObject("Excel.Application")
Set xlWb = xlApp.workbooks.Open("G:\Path\Path2\Path3\ExcelFile.xls")
Set xlWs = xlWb.Worksheets("Data")

Then, I have code to transfer data and massage it a little bit, and then I
close my references with this:

rst.Close
cnt.Close
Set rst = Nothing
Set cnt = Nothing

' Release Excel references
Set xlWs = Nothing
Set xlWb = Nothing
Set xlApp = Nothing

But then, when I try to open those excel files to see if everything looks
OK, they are locked for editing and the instances of Excel are still open. I
end up having to use the task manager to shut them down. Where did I go
wrong ???

Richard Choate
 

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