Hi.
Got a question.
I got a timer that counts from 1 min down, then runs a Sub called shutdown.
The problem is, when it closes, it leaves a open empty excel program open, not completely shutting it down, i fixed this with the code under, but if i got a other workbook active, it asks that to save it or not, as it wants to close that as well.
I only want to close the current one.
I managed to get it to work, if i got 2 active, it closes perfect, but if i only got the current active, it leaves a empty book open.
Take a look at my code:
Sub ShutDown()
'Application.DisplayAlerts = False
With ThisWorkbook
'ThisWorkbook.Save
' .Saved = True
' .Close
Application.DisplayAlerts = False
ThisWorkbook.Save
Application.DisplayAlerts = True
Application.Quit
End With
End Sub
If i use these:
'Application.DisplayAlerts = False
With ThisWorkbook
'ThisWorkbook.Save
' .Saved = True
' .Close
it works, but leaves a empty one, but closes the current perfectly if i got multiple books open.
If i use:
Application.DisplayAlerts = False
ThisWorkbook.Save
Application.DisplayAlerts = True
Application.Quit
Then it closes the active book perfectly, leaving no books open, but if i got multiple open, it wants to close them as well.
Is there a way to make it so, if its the only active, it closes it, leaving no empty ones, and if i got multiple open, it only closes the current one?
Thanks
Got a question.
I got a timer that counts from 1 min down, then runs a Sub called shutdown.
The problem is, when it closes, it leaves a open empty excel program open, not completely shutting it down, i fixed this with the code under, but if i got a other workbook active, it asks that to save it or not, as it wants to close that as well.
I only want to close the current one.
I managed to get it to work, if i got 2 active, it closes perfect, but if i only got the current active, it leaves a empty book open.
Take a look at my code:
Sub ShutDown()
'Application.DisplayAlerts = False
With ThisWorkbook
'ThisWorkbook.Save
' .Saved = True
' .Close
Application.DisplayAlerts = False
ThisWorkbook.Save
Application.DisplayAlerts = True
Application.Quit
End With
End Sub
If i use these:
'Application.DisplayAlerts = False
With ThisWorkbook
'ThisWorkbook.Save
' .Saved = True
' .Close
it works, but leaves a empty one, but closes the current perfectly if i got multiple books open.
If i use:
Application.DisplayAlerts = False
ThisWorkbook.Save
Application.DisplayAlerts = True
Application.Quit
Then it closes the active book perfectly, leaving no books open, but if i got multiple open, it wants to close them as well.
Is there a way to make it so, if its the only active, it closes it, leaving no empty ones, and if i got multiple open, it only closes the current one?
Thanks