Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
Dim Rep%
If Application.Workbooks.Count = 1 Then
If Application.Visible = False Then
Rep% = MsgBox(prompt:="La fermeture du UserForm implique que l'application Excel soit fermée." & vbLf & _
"Voulez-vous réellement fermer l'application Excel ?", Buttons:=vbOKCancel)
If Rep% = vbOK Then
If Not AppClass Is Nothing Then Set AppClass = Nothing
ThisWorkbook.Save
Application.Quit
Else
Cancel = True
End If
End If
Else
UserFormVisible = False
End If
End Sub