Excel 2003 will not terminate with application.quit


G

Guest

When I use automation (VB, VBS, etc.) to open a workbook
in Excel 2003, the Quit method does not terminate the
Excel process. Each time the script is executed, another
Excel process is started, using about 10MB memory. I need
to use Task Manager to kill the process, lest I run out
of memory in a few days. Here is a sample script:

Dim XLApp
Dim XLWkb
Set XLApp = CreateObject("Excel.Application")
Set XLWkb = XLApp.Workbooks.Open("c:\xlbug.xls")
XLWkb.Close
Set XLWkb = Nothing
XLApp.Quit
Set XLApp = Nothing
'EXCEL.EXE should not be running anymore, but it is!

You can open any workbook file. I tested with a small
workbook file (two cells only) or a single-line text
file - same result. This problems does not happen with
Excel 2000.

Thanks,

Peter Schellenbach
 
Ad

Advertisements

D

Dave Peterson

I tried your code as a .vbs script and excel closed for me.

In fact, I thought maybe there was a prompt waiting for you so the xlwkb.close
line was still waiting.

If you have a volatile function (like =today(), =now(), =rand()), then that
workbook will recalculate when you open it. And maybe excel was waiting for you
to answer the "The workbook has changed--do you want to save it?" prompt.

But that message popped up nice and clear when I tested. (You would have
noticed it.)

Maybe adding

xlapp.visible = true

to your script would help you find the problem.

(tested with winxp home and xl2003)
 
J

Jake Marx

Hi Peter,

I would suggest adding False as the first argument to the Close method:

XLWkb.Close False

If you don't do this, Excel may, as Dave mentioned, be waiting for you to
answer "do you want to save changes". Were these workbooks created with
Excel 2000? If so, that would explain what you're seeing. Excel 2000
workbooks will always prompt you to save upon close when they are opened in
Excel 2003.

But regardless of what's causing the problem, adding False is a good
practice.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]
 
D

Dave Peterson

Unless you want to save those changes <vbg>.

Jake said:
Hi Peter,

I would suggest adding False as the first argument to the Close method:

XLWkb.Close False

If you don't do this, Excel may, as Dave mentioned, be waiting for you to
answer "do you want to save changes". Were these workbooks created with
Excel 2000? If so, that would explain what you're seeing. Excel 2000
workbooks will always prompt you to save upon close when they are opened in
Excel 2003.

But regardless of what's causing the problem, adding False is a good
practice.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]

Peter said:
When I use automation (VB, VBS, etc.) to open a workbook
in Excel 2003, the Quit method does not terminate the
Excel process. Each time the script is executed, another
Excel process is started, using about 10MB memory. I need
to use Task Manager to kill the process, lest I run out
of memory in a few days. Here is a sample script:

Dim XLApp
Dim XLWkb
Set XLApp = CreateObject("Excel.Application")
Set XLWkb = XLApp.Workbooks.Open("c:\xlbug.xls")
XLWkb.Close
Set XLWkb = Nothing
XLApp.Quit
Set XLApp = Nothing
'EXCEL.EXE should not be running anymore, but it is!

You can open any workbook file. I tested with a small
workbook file (two cells only) or a single-line text
file - same result. This problems does not happen with
Excel 2000.

Thanks,

Peter Schellenbach
 
G

Guest

Thanks Dave & Jake

After reading your responses, I loaded up a fresh copy of XP Pro / SP2 and
Office 2003 / SP1 on a test computer and tried the same test script. No
problem. However on my main desktop system, Excel indeed does not terminate.
It does not show up in the Applications, but does show up in Processes, and
chews up 10-20MB each time the script is run. I have a customer reporting the
same problem, which is why I am investigating. I did try adding False to the
XLWkb.Close method, but no difference. I also added XLApp.Visible=True to see
if any unexpected dialogs popped up, but nothing showed up and the Excel
process still did not terminate.

I also ran msconfig and selected "diagnostic startup" just in case some
other program was interferring, but still no luck.

Any more ideas?

Thanks,

Peter
 
Ad

Advertisements

D

Dave Peterson

The little sample script suffered from the same problem???

I don't have any other suggestions for that, but if that actually worked ok,
then maybe in the real script, you didn't release all your objects???

(But that's just one wild guess.)
 
T

tedgar

I am experiencing the exact same problem, BUT I do not have the Googl
Desktop Search AddIn. I am seeing this on an XP Pro machine as well a
a W2K machine

Could there be any other addIns that can cause a similar symptom

Thanks
To
 
Ad

Advertisements

F

Fredrik Wahlgren

tedgar said:
I am experiencing the exact same problem, BUT I do not have the Google
Desktop Search AddIn. I am seeing this on an XP Pro machine as well as
a W2K machine.

Could there be any other addIns that can cause a similar symptom?

Thanks,
Tom

None that I'm aware of. It may make sense to create a minimal application
that simply starts Excel and the calls Quit followed by a release of the
refernec. It's possible that ther real program you have doesn't release all
the refernces it holds. If the minimal program works OK, you probably have
this kind of problem.

Best Regards,
Fredrik
 

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