Solved

MS Excel staying resident in task manager

Posted on 2013-01-17
4
353 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
ID: 38788234
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
ID: 38788373
Thanks for the quick response. I will update the code and test. I will let you know...Thanks
0
 

Author Closing Comment

by:clynch302
ID: 38788926
Looked like it worked. Thanks for your time.
0
 
LVL 29

Expert Comment

by:gowflow
ID: 38789075
your welcome.
gowflow
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Cascading dropdown 9 27
VS2015 Redefinition errors 4 27
Most Consistent Performer 4 20
remove upper case characters in excel 4 0
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

910 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

24 Experts available now in Live!

Get 1:1 Help Now