Reputation: 191
In the macro I'm running, I end with closing the last Excel Workbook that's open. When I run it everything closes except one window which doesn't have a spread sheet, just a light-blue backdrop. Am I using a wrong command or is there just no way to close all open windows?
Here is a post asking my exact question, but the solution isn't working for me.
Here are the last two commands that I'm using:
'
' Closes Populated JD Form
'
Workbooks(name).Close SaveChanges:=False
'
' Closes Transfer Template
'
Workbooks("Transfer Template.xlsm").Close SaveChanges:=False
Thanks in advance!!!
Upvotes: 1
Views: 16767
Reputation: 1
Once I removed atpvbaen.xls from my references, application.quit worked as advertised.
I was tearing my hair out - until I realized I had atpvbaen.xls set as a reference - which was ANOTHER excel thread left alive. I didn't need it for this application, so I disabled it. In the VB Editor, Tools => References un-check atpvbaen.xls.
If I had needed it, maybe shutting that one down deliberately would have worked.
Upvotes: 0
Reputation: 6216
Don't turn the display alerts off as it will suppress any genuine questions.
Use this instead
ActiveWorkbook.Saved = True
Application.Quit
This will stop Excel for asking about saving changes as it now thinks that it has been saved already. A good example of this is your personal macro workbook, I use mine a LOT and am always creating or modifying code in there. If I turn the alert off and there are changes in my personal workbook, I lose them all.
Try not to bulk fix possible scenarios where possible. Another example is errors, have an error trapping routine and deal with it as needed as opposed to a blanket statement of on error resume next.
Upvotes: 7
Reputation: 10705
To make sure the question doesn't remain unanswered, using both suggestions
(credit to @DeanOC and @user1274820)
'Closes Populated JD Form
Workbooks(Name).Close SaveChanges:=False
'Closes Transfer Template
Workbooks("Transfer Template.xlsm").Close SaveChanges:=False
With Application
.DisplayAlerts = False
.Quit
End With
Upvotes: 1