Hi
Whenever a users clicks "X" to close the workbook, a pop up needs to show asking if they want to quit without saving. If they click no, I want it to open the save as dialogue box. If the user then saves the file with the same name I need it to show a pop up stating they need to enter a different name (to prevent overwriting) and then go back to the save as dialogue box. If the user clicks cancel, a pop up should show up.
Up until now I came up with following code. It does what I want except it doesn't prevent the user from overwriting the file.
Can you pls help me out?
Regards,
Tino
Sub Auto_Close()
Dim Answer As String
Dim bFileSaveAs As Boolean
Answer = MsgBox("Are you done writing the orders for this supplier?" & vbCrLf & "Click no, if you want to save the file to continue later." & " (" & "Save under a different name!" & ")", vbQuestion + vbYesNo, "Finish?")
If Answer = vbYes Then
ThisWorkbook.Saved = True
Else
bFileSaveAs = Application.Dialogs(xlDialogSaveAs).Show
If Not bFileSaveAs Then MsgBox "User cancelled!", vbCritical
End If
End Sub
Bookmarks