Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim tmpname As String
Dim test As Boolean
test = False
For Each feufeuille In ActiveWorkbook.Worksheets
If feufeuille.Name = 'Journal' Then test = True
Next
If test = False Then
ActiveWorkbook.Worksheets.Add
tmpname = ActiveWorkbook.ActiveSheet.Name
Sheets(tmpname).Name = 'Journal'
Range('A1').Value = 'Nom'
Range('B1').Value = 'Début session'
Range('C1').Value = 'Fin session'
Range('D1').Value = 'Durée'
ActiveWorkbook.ActiveSheet.Visible = False
End If
If ActiveWorkbook.Worksheets('Journal').Range('B65356').End(xlUp).Value <> 'Début session' Then
ActiveWorkbook.Worksheets('Journal').Range('B65356').End(xlUp).Offset(0, 1).Value = Now()
ActiveWorkbook.Worksheets('Journal').Range('B65356').End(xlUp).Offset(0, 2).FormulaR1C1 = '=RC[-1] - RC[-2]'
End If
Sheets('Journal').Visible = False
End Sub
Private Sub Workbook_Open()
Dim tmpname As String
Dim test As Boolean
test = False
For Each feufeuille In ActiveWorkbook.Worksheets
If feufeuille.Name = 'Journal' Then test = True
Next
If test = False Then
ActiveWorkbook.Worksheets.Add
tmpname = ActiveWorkbook.ActiveSheet.Name
Sheets(tmpname).Name = 'Journal'
Range('A1').Value = 'Nom'
Range('B1').Value = 'Début session'
Range('C1').Value = 'Fin session'
Range('D1').Value = 'Durée'
ActiveWorkbook.ActiveSheet.Visible = False
End If
ActiveWorkbook.Worksheets('Journal').Range('A65356').End(xlUp).Offset(1, 0).Value = Environ('username')
ActiveWorkbook.Worksheets('Journal').Range('B65356').End(xlUp).Offset(1, 0).Value = Now()
Sheets('Journal').Visible = False
End Sub