Application Quit does not work

  • Thread starter Thread starter Ed Davis
  • Start date Start date
E

Ed Davis

When I have the personal file loaded the Application.Quit does not work.
I close all workbooks in a macro before I use the quit statement but it
still does not work.
Any Ideas?
 
I also found that it does not quit at all.
All workbooks are closed but the application is still running.
I get a blue Excel screen no workbook or sheets.
 
Hi,

If unsaved workbooks are open when you use this method, Microsoft Excel
displays a dialog box asking whether you want to save the changes. You can
prevent this by saving all workbooks before using the Quit method or by
setting the DisplayAlerts property to False. When this property is False,
Microsoft Excel doesn’t display the dialog box when you quit with unsaved
workbooks; it quits without saving them.

If you set the Saved property for a workbook to True without saving the
workbook to the disk, Microsoft Excel will quit without asking you to save
the workbook.

From the Help system
 
This is my code.
No matter what I do it does not quit.

If just the Personal file is open and I run the Quit Sub It works fine.
otherwise....


Answer = MsgBox("Do you want to Exit Excel Also?", vbYesNo + vbQuestion,
"Done with all work?")
If Answer = vbYes Then
ActiveWorkbook.Close Savechanges = True
CloseAll
Application.DisplayAlerts = False
Call Quit
End If
End Sub


Sub Quit()
Application.Quit
End Sub
 
Hi Ed,

Not sure about myself but perhaps you are closing the wrong book first and
do not have code anymore to close the others and quit the application.

Try to include in your macro a check on the worbook.name containing the
code.


Sub test()
Dim wb As Workbook
Application.DisplayAlerts = False

For Each wb In Workbooks
If wb.Name <> ThisWorkbook.Name Then
wb.Close
End If
Next

''''save your last workbook here.
Application.Quit
End Sub
Wkr,

JP
 
Here is one I use to save all open workbooks and quit

Sub CLOSE_ALL()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each w In Application.Workbooks
w.Save
Next w
Application.Quit
End Sub
 
I have tried this and the "Personal" workbook never closes.
The only two books open is the one with the code and personal.
The one with the code closes but not the personal


--
Thank You in Advance
Ed Davis
Don Guillett said:
Here is one I use to save all open workbooks and quit

Sub CLOSE_ALL()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each w In Application.Workbooks
w.Save
Next w
Application.Quit
End Sub
 
I have not had this problem. Try this. Rename your personal.xls file. Now
try my macro. If it works, re-create a new personal.xls by recording a macro
to it. Then try again. If all is OK, copy your old renamed personal.xls to
the same location (use windows find)??. Delete the new personal.xls and then
rename the old to personal.xls........
????

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(e-mail address removed)
Ed Davis said:
I have tried this and the "Personal" workbook never closes.
The only two books open is the one with the code and personal.
The one with the code closes but not the personal
 
Sorry that did not work after all.
I created a workbook called "Personal.xls"
No macros and just 1 sheet.

When I run the "CLOSE_ALL" sub from "Personal" and the other workbook is
present it closes the other workbook and exits Excel.
When I run "CLOSE_ALL" from the workbook that holds the code it close the
other workbook but not "Personal".
 
I just figured it out.
It appears I was not just saving but also closing the active workbook before
the application.quit statement.

Thank you very much everyone for your help.
 
Now it looks like the closing of the files is what did it.
I first had it saving all files and then closing all files.
I set it to save all files and now Quit and it seems to be working correctly
now.
I think that you really do not want to close the file that holds the CODE
because it is closed before the Quit statement.
 
Yes I am sorry I was running an ALL_Close macro. I learn from my mistakes.
Thanks again for your help.
 
Back
Top