ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Auto Close and Save (https://www.excelbanter.com/excel-programming/303410-auto-close-save.html)

scottwilsonx[_7_]

Auto Close and Save
 
Hi everyone. Hopefully this is an easy question to answer:

I want to set an automatic macro to close the file and exit excel.

I also want another one, which prompts the user to save the file an
then close.

Any ideas ?

Thanks
Scott

--
Message posted from http://www.ExcelForum.com


papou[_9_]

Auto Close and Save
 
Hi Scott
Sub CloseFileAndExit()
ThisWorkBook.Close(True) 'Or false if you do not wish to save (since you did
not mention)
Application.Quit
End Sub

Sub SaveAndClose()
Do While Application.Dialogs(xlDialogSaveAs).Show = False
Loop
ThisWorkbook.Close
Application.Quit
End Sub

HTH
Cordially
Pascal


"scottwilsonx " a écrit dans
le message de ...
Hi everyone. Hopefully this is an easy question to answer:

I want to set an automatic macro to close the file and exit excel.

I also want another one, which prompts the user to save the file and
then close.

Any ideas ?

Thanks
Scott.


---
Message posted from http://www.ExcelForum.com/




scottwilsonx[_8_]

Auto Close and Save
 
Pascal, thanks for the code you kindly sent thru. Works perfectly!

Much obliged.

Scott

--
Message posted from http://www.ExcelForum.com


papou[_9_]

Auto Close and Save
 
Glad it helped

Cordially
Pascal

"scottwilsonx " a écrit dans
le message de ...
Pascal, thanks for the code you kindly sent thru. Works perfectly!

Much obliged.

Scott.


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 05:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com