SoFunction
Updated on 2025-03-10

Excel custom close button implementation code

I have encountered such a requirement. When Excel is closed, do not save the window of Excel itself, but only use custom ones.

The first thing to do is to trigger when clicking to close.

Second; after triggering, that window cannot still pop up

Third: After cancellation, you must be able to stop the program

After exploring this for a long time, I finally found a solution through the combination:

Execute first

Private Sub Workbook_BeforeClose(Cancel As Boolean)
   If C_Msg.PostA("Com_Err023", , True, 1) = vbOK Then
 
     Dim xxx As String
     xxx = "Yes"
    Cancel = False
   Else
     Dim sss As String
      sss = "No"
      Cancel = True
   End If
End Sub

Execute again

Sub Auto_Close()
 
     = True
    If  = 1 Then
      
    End If
    ' False
End Sub

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.