I want the macro to give the user the option (yes or no) after the message of
"Save File As ...". The macro appear below. Any suggestions will be
greatly appreciated.
> Sub cmdExit_Click()
> Dim Response As String
> Dim msg As String
> Dim Style As String
> Dim sPath As String
> Dim sFilename As String
> Dim ans
>
> msg = "Are you sure you want to Exit the application and Close Excel?"
> Style = vbYesNo + vbInformation + vbDefaultButton2
>
> Response = MsgBox(msg, Style)
> If Response = vbYes Then
> sPath = "C:\MetroWest\"
> sFilename = Format(Worksheets("MainMenu").Range("C5").Value,
> "mm-dd-yyyy")
> ans = MsgBox("Save File As " & sFilename)
> If ans = vbOK Then
> ActiveWorkbook.SaveAs sPath & sFilename
> ActiveWorkbook.Close savechanges:=True
> Application.Exit
> Application.StatusBar = "Application Closing."
> End If
> Else
> ActiveWorkbook.Activate
> End If
>
> End Sub
Bookmarks