Excel Object Variable not released

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

I have Access 2002 sp3. In my vba code, I delcared and set an object
variable to Excel. I was able create the instance, have it open a workbook
and do a fews things through code. However, when it was time to close and
save the workbook, and close the instance of Excel and destroy the Excel
object variable, I was unable to. My code looked like:

oExcel.ActiveWorkbook.close
oExcel.Application.Quit 'I tried to use oExcel.Quit, but both do not work.
Set oExcel = Nothing

After the last line, I checked the task manager and I still see the
instance. I then opened another instance of Excel and tried to open the same
file that I had the first instance open. But when I tried, Excel came back
saying the file is being used by me and gave me the option to open it as a
Read Only or Notify.
Does any one know why this is? Thanks for sharing your thoughts.

Ben

--
 
This is most commonly caused by incomplete or incorrect object referencing.
You should always be sure when you are creating a reference to object in the
Excel object model, that you reference completely from the application level
down. What happens if the reference is ambiguous is that Access doesn't know
what higher level object it belongs to, so it creates an additional
application level reference for it. So when you issue the Quit command, it
quits one, but leaves the other open. Review your code to be sure your
references are fully qualified.
 
Hi Ben,

do you have any other object references -- like to a
workbook or a sheet? Can you post the complete code you are
using?

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
 
Back
Top