Solved

MS Excel staying resident in task manager

Posted on 2013-01-17
4
372 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

730 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