Solved

MS Excel staying resident in task manager

Posted on 2013-01-17
4
362 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Dropbox in Windows Server 2008 4 31
Excel Spacing Anomaly 4 23
how to add loop into this VBA 3 29
excel count months in date range 6 12
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

777 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