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

I have found code to prevent closure of an application by clicking on the Red X. I placed it on Thisworkbook & it prevents the user from closing by clicking on the Red X.
Here is the code as written at present:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If CloseMode = 0 Then
Cancel = True
MsgBox "The X is disabled, please click on the Exit button.", vbCritical
End If
End Sub

This code is also preventing closure of the workbook/application. I think that once the code runs it is not released, I have not found a solution.
I see the code working this way. The user clicks on the X & the above message, pops up & that is the end of the process. The user clicks on Exit & it closes. I do have working code to close the workbook/application. However when the Exit button is clicked at present it goes back to the above code.
Something weird is going on . I went back in to the application, Clicked the X, & the message popped up once, & waited for me to respond.

Last edited by FrancisM : June 25th 19 at 12:38 PM Reason: Recent change in operation