G
Gun_Maddie
Last week I asked a question as how to get the save as dialog box to
appear. I finally was able to get it to appear. I was wondering what
if someone hits the cancel button in the dialog box, ie they decide
they need to continue to work. Here is the code I have written so
far. My problem is that the workbook is closing if I hit the cancel
button in the save as dialog box. What I would like to happen is a
message box to appear and ask if they would like to close without
saving.
Application.DisplayAlerts = False
' Brings up the Save As Dialog Box
Msg = "Would you like to save the expense report?"
Ans = MsgBox(Msg, vbQuestion + vbYesNo)
Select Case Ans
Case vbYes
Application.Dialogs(xlDialogSaveAs).Show
Call ShowToolBars
ActiveWorkbook.Close
' If an employee hits the cancel button from the Save As Dialog Box
If Cancel = True Then
Answer = MsgBox("Do you want to close the workbook _
without saving?", vbQuestion + vbYesNo)
Select Case Answer
Case vbYes
Call ShowToolBars
ActiveWorkbook.Close
Case vbNo
Range("B15").Select
End Select
End If
Case vbNo
Call ShowToolBars
ActiveWorkbook.Close
End Select
End Sub
appear. I finally was able to get it to appear. I was wondering what
if someone hits the cancel button in the dialog box, ie they decide
they need to continue to work. Here is the code I have written so
far. My problem is that the workbook is closing if I hit the cancel
button in the save as dialog box. What I would like to happen is a
message box to appear and ask if they would like to close without
saving.
Application.DisplayAlerts = False
' Brings up the Save As Dialog Box
Msg = "Would you like to save the expense report?"
Ans = MsgBox(Msg, vbQuestion + vbYesNo)
Select Case Ans
Case vbYes
Application.Dialogs(xlDialogSaveAs).Show
Call ShowToolBars
ActiveWorkbook.Close
' If an employee hits the cancel button from the Save As Dialog Box
If Cancel = True Then
Answer = MsgBox("Do you want to close the workbook _
without saving?", vbQuestion + vbYesNo)
Select Case Answer
Case vbYes
Call ShowToolBars
ActiveWorkbook.Close
Case vbNo
Range("B15").Select
End Select
End If
Case vbNo
Call ShowToolBars
ActiveWorkbook.Close
End Select
End Sub