Frncis
Member
I had a user that would not use the exit active X button, that the code below was created, 2 friends helped me with this code.
If Yes is clicked, workbook/application closes.
If NO is clicked, workbook/application does not close, but does not allow data entry.
If clicked a second time the workbook/application closes.
I am trying allow the user to enter data if the No is chosen.
I have googled & have not found this problem listed or a solution.
I believe it has to do with the No response, but I am not certain about the proper wording.
Code:
Public Ok2Close As Boolean
Sub CloseMacro()
Call OVR_MEETING_1_Close
'Prevents closure of application by clicking on application X.
'Second half of code found on Private Sub Workbook_BeforeClose(Cancel As Boolean)
'Cancel = Not Ok2Close
Call OVR_MEETING_1_Close
Ok2Close = True
ThisWorkbook.Close SaveChanges:=True
Application.Quit
Ok2Close = False
End Sub
Sub OVR_MEETING_1_Close()
'This code does the following tasks.
'1. Asks if you want the application closed.
'2. Returns the application to the home page (If yes).
'3. Does any final calculations (If Yes).
'4. Closes both the work book & the application (if yes).
Dim Msg As String, Ans As Variant
Msg = "Would you like to close Career Link meeting List?"
Ans = MsgBox(Msg, vbYesNo, "Voc. Rehab. - Career Link")
Select Case Ans
Case vbYes
Dim i As Long
Application.ScreenUpdating = False
For i = 1 To ThisWorkbook.Sheets.Count
Application.Goto Reference:=Sheets(i).Range("A1"), Scroll:=True
Next i
Application.ScreenUpdating = True
Sheets("TOC").Select
Application.Calculation = xlCalculationAutomatic
Ok2Close = True
Application.Quit
Ok2Close = False
ThisWorkbook.Close SaveChanges:=True
End Select
End Sub
If NO is clicked, workbook/application does not close, but does not allow data entry.
If clicked a second time the workbook/application closes.
I am trying allow the user to enter data if the No is chosen.
I have googled & have not found this problem listed or a solution.
I believe it has to do with the No response, but I am not certain about the proper wording.