Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Application.Quit recently changed behavior to leave Excel running

Status
Not open for further replies.

baconfortek

Technical User
Jan 30, 2009
3
US
In the last couple of weeks I have begun having trouble with application.quit not actually shutting down Excel. The very simplified code below leaves Excel running on two computers and completely closes Excel on two different computers.
Code:
Sub closeMe()
  Application.DisplayAlerts = False
  ThisWorkbook.Save
  ActiveWorkbook.Saved = True
  Application.Quit
  Exit Sub
End Sub
Besides Application.Quit, each of the other lines was added at the suggestion of various other threads on Excel failing to quit. Any ideas for what to try next?
 
What changes after the code runs?
What happens without Application.DisplayAlerts = False?
Are there any other workbooks in current instance?
Is the above procedure in standard module?
Is there a workbook in print preview mode?
Is there a single excel instance on all computers?

Try to close (and process if necessary) other workbooks before closing excel, you may also break code after and see what is going on:
Code:
Dim wb As Workbook
With Application
    For Each wb In Application.Workbooks
        If Not wb Is ThisWorkbook Then
            wb.Saved = True
            wb.Close
        End If
    Next wb
End With


combo
 
After additional testing last night, I found Excel stays running whenever I open a file on a network drive with the latest round of windows updates. On an updated computer, when opening any Excel file on our network, then closing the file, the Excel instances stays open in task manager. This occurs whether I manually close excel with the X in the upper right corner or close it using application.quit. I am assuming the file closes because the lock file disappears.

-Combo
The only thing in my test workbook is the code shown. I had started with only the application.quit line, and added all of the other lines as part of trouble shooting.Before testing, I closed all other excel instances and verified that I only opened a single workbook.
 
The issue seems to have resolved itself sometime this morning. I have idea what changed this morning between 8 am and 9 am.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top