Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
Dim FM
If Application.Workbooks.Count = 1 Then
If Application.Visible = False Then
FM = MsgBox(prompt:=" " & vbLf & _
"Voulez-vous réellement fermer ?", Buttons:=vbOKCancel)
If FM = vbOK Then
If Not AppClass Is Nothing Then Set AppClass = Nothing
' ThisWorkbook.Save
Application.Quit
Else
Cancel = True
End If
End If
Else
If Application.Visible = True Then
FM = MsgBox(prompt:=" " & vbLf & _
"Voulez-vous réellement fermer ?", Buttons:=vbOKCancel)
If FM = vbOK Then
If Not AppClass Is Nothing Then Set AppClass = Nothing
' ThisWorkbook.Save
ThisWorkbook.Close
Else
Cancel = True
End If
End If
End If
End Sub