GeorgeWhite
New Member
- Joined
- Apr 20, 2017
- Messages
- 27
Hello
I am looking for a way I can open a SaveAs dialog using VBA, then if the user hits cancel it will show a msgbox with "You need to save the document before you can continue." on a vbOKCancel + vbCritical popup. If the user then selects cancel it will close the workbook but if they select ok it will bring the SaveAs dialog back up but I then want it too keep repeating it, if they select cancel again it will repeat the steps. If they select ok and successfully save the file it will continue to the next part of my code which is just activating another workbook and closing it.
I currently have this but I am willing to use something else.
Many thanks
I am looking for a way I can open a SaveAs dialog using VBA, then if the user hits cancel it will show a msgbox with "You need to save the document before you can continue." on a vbOKCancel + vbCritical popup. If the user then selects cancel it will close the workbook but if they select ok it will bring the SaveAs dialog back up but I then want it too keep repeating it, if they select cancel again it will repeat the steps. If they select ok and successfully save the file it will continue to the next part of my code which is just activating another workbook and closing it.
I currently have this but I am willing to use something else.
Code:
Dim bFileSaveAs As Boolean
bFileSaveAs = Application.Dialogs(xlDialogSaveAs).Show
If Not bFileSaveAs Then MsgBox "You need to save the document before you can continue.", vbOKCancel + vbCritical
ActiveWorkbook.Close savechanges:=False
Many thanks
Last edited: