View Single Post
  #3   Report Post  
FrancisM FrancisM is offline
Junior Member
 
Posts: 14
Default Using the red X (Upper right hand corner) for another purpose.

Thank you. I did not think of that. The code works, however, 2 things occur. 1). The msgBox occurs 2x. 2) The workbook closes, but not the application. The same thing happens when the exit button is clicked & call "Exit_Referrals" is present. If "Call Exit_Referrals" is not present, the msgbox appears 1x, and both the workbook & application close without any problem. I have tried to find a solution, but have not been successful.
Here is the current code:


Option Explicit

Sub Exit_Referrals()
Dim MsgBoxResult As Long

MsgBoxResult = MsgBox("Would you like to Exit the Referral Workbook?" & vbCr, _
vbYesNo, "Voc. Rehab. - Referral")
If MsgBoxResult = vbNo Then
Exit Sub
ElseIf MsgBoxResult = vbYes Then
Sheets("TOC").Select
Application.Calculation = xlCalculationAutomatic
Application.Quit
ThisWorkbook.Close SaveChanges:=True
End If
End Sub


When I moved "Application.Quit" after close, the workbook closed, but not the application.

Last edited by FrancisM : June 24th 19 at 01:01 PM Reason: Additional Info