Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim i, j As Integer
Dim texte As String
Dim Wksht As Worksheet
On Error Resume Next 'Fermeture de Data Passdown
Workbooks(Range("NameDataPassdown").Value).Close SaveChanges:=False
On Error GoTo 0
If Userallowed = False Then Exit Sub
Application.ScreenUpdating = False
If Range("Freeaccess").Value = True Then
Or ActiveWorkbook.ReadOnly Then Exit Sub
SortieSansEnregistrement = True
Sheets("LOG").Select
On Error Resume Next
ActiveSheet.ShowAllData
Range("RefID").End(xlDown).Select
On Error GoTo 0
Call Enregistrement 'Affichage feuille warning + enregistrement
If MsgBox("Passdown is already saved." & Chr(10) & _
"Do you want to create a new copy in the Free To Use Folder ?" & Chr(10) & Chr(10) & _
"A copy must be created at the end of each shift.", vbYesNo) = vbNo Then Exit Sub
'Je cache les feuilles non free to use + administrator pour access a tous
Call AffichFeuillesUtilisateurs
'J'autorise l'acces de tous au fichier dans Folder "Free to use" avant de sauvegarder
Range("Freeaccess").Value = 1
'Sauvegarde d'une copie actualisee dans Folder "Free to use"
ActiveWorkbook.SaveAs Filename:= _
Range("filename").Value & " Passdown by " & Range("Currentuser").Value & " " & Format(Now, "dd-mm-yy hh-mm-ss") & ".xls"