Solved

MS Excel staying resident in task manager

Posted on 2013-01-17
4
342 Views
Last Modified: 2013-01-17
Included below is some simple VB code from a spreadsheet that is called via a batch
file every hour by the Windows Task Scheduler. It basically opens various Excel
workbooks and saves a certain portion of each one as .htm output in a common directory.
It takes about 20 minutes to run and generates about 650 individual files each time.
The code ran fine for many years, but recently we began having an issue where all of
the code executes OK, but Excel stays resident in the Windows Task Manager, which
causes a problem the next time the file tries to run because Excel thinks that the
file is still open. We have upgraded the server from Windows 2003 32bit to Windows 2008 64bit. We are running MS Excel 2007. While doing some searches on the internet we discovered this brief
article (http://www.tushar-mehta.com/excel/vba/xl_doesnt_quit/) which describes exactly
what we are seeing.  Having somewhat limited knowledge of VB, we are wondering if the
solution described in that article would be of use to us, and if so, we need a little
guidance as to how and where to implement it in our code. If perhaps there is something
else we could try to resolve the problem, that would be great too. Thanks for any input.
Code.txt
0
Comment
Question by:clynch302
  • 2
  • 2
4 Comments
 
LVL 29

Accepted Solution

by:
gowflow earned 500 total points
Comment Utility
yes remove the instruction
Application.Quit
from the Workbook_Open and put it in

Workbook_BeforeClose

so that the code in workbook become like the attached following:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
    
    Application.Quit
    
End Sub

Private Sub Workbook_Open()

    Call generate_htm_files
    ActiveWorkbook.Saved = True
    ActiveWorkbook.Close
    
End Sub

Open in new window


gowflow
0
 

Author Comment

by:clynch302
Comment Utility
Thanks for the quick response. I will update the code and test. I will let you know...Thanks
0
 

Author Closing Comment

by:clynch302
Comment Utility
Looked like it worked. Thanks for your time.
0
 
LVL 29

Expert Comment

by:gowflow
Comment Utility
your welcome.
gowflow
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now