When does automation object get cleaned up?

G

Guest

I want to generate an Excel spreadsheet from my Access data, open the
resulting Excel file, and let the user decide what to do from there.

So, my module will not close the Excel application object.

I remember a time when I was first learning about automation, and I kep
forgetting to close the application objects, or didn't set them to Nothing.
Windows got very upset, and I had to reboot sometimes.

So, my question now is, if I leave close my Access module without getting
rid of the Excel application object, will Access clean it up for me? Will
there by anything left after the module is closed, but the Excel workbook is
still open?
 
D

Douglas J. Steele

I don't think so. I'm sure I've seen incidences of Excel left behind after
debugging faulty code...
 
G

Guest

Um, I don't think this is an answer.

I want the Excel left open, I just want to make sure that there aren't any
VBA objects still hanging around when I close that module, but don't put in
the following line

set ojbExcel = Nothing

before I close the modue.

The user might choose to run this code many times in a session, so if an
object is not cleaned up when the module closes, it could cause a problem.

If it is cleaned up when the module closes, then why do we need to put that
line in?
 
D

Douglas J. Steele

I'm sorry, I don't understand your follow-up question.

I read your question as being "If Access shuts down, will it shut down any
instances of Excel that were opened while the Access application was
running." My response was "No, it won't shut them down: you have to
explicitly shut them down." What exactly are you asking?
 

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