Private Sub Workbook_BeforeClose(Cancel As Boolean)
If ActiveSheet.Range("i7") = "ICI" Then
Application.EnableEvents = False
MsgBox ("Affecter avant de quitter")
UsFMsg4.Show
Cancel = True
Application.EnableEvents = True
Exit Sub
End If
If Sheets("SMS RdV").Range("c27") <> "" Then
Application.EnableEvents = False
MsgBox ("envoi SMS avant de quitter")
Sheets("SMS RdV").Select
Cancel = True
Application.EnableEvents = True
Exit Sub
End If
dl = Sheets("RdV_transfert").Range("A" & Rows.Count).End(xlUp).Row
If Sheets("RdV_transfert").Cells(dl, 4) = "" Then
Application.EnableEvents = False
MsgBox ("mettre l'agenda Client à jour du dernier RdV")
Sheets("RdV_transfert").Select
Cancel = True
Application.EnableEvents = True
Exit Sub
End If
If Sheets("Appels").Range("n1") = 1 Then
Application.EnableEvents = False
Sheets("Appels").Select
MsgBox ("N° cliqué NON affecté : Normal Dr ?" & Chr(10) & "Affecter ou clic X pour annuler")
Cancel = True
ActiveSheet.Unprotect Password:=""
Columns("N:N").Select
Selection.Find(What:="x", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
Application.EnableEvents = True
ActiveCell.Offset(0, -3).Select
Exit Sub
End If
Sheets("Appels").Select
Sheets("Appels").Unprotect Password:=""
Sheets("Appels").Range("m1") = "TEXTBOX FERME"
With Sheets("Appels").Range("m1").Interior
.Color = RGB(55, 86, 35)
End With
Sheets("Appels").Protect Password:="", DrawingObjects:=True, Contents:=True, Scenarios:=True
With Sheets("Appels")
.TextBox1.Visible = False
End With
'Selection.AutoFilter 'ôte le filtre
Application.OnKey "%{F8}"
RétabliMenu
' ActiveWorkbook.Save
' ActiveWorkbook.RunAutoMacros Which:=xlAutoClose
.Save
If Workbooks.Count = 1 Then Application.Quit Else .Close
End Sub