Dim timerstart
Const durée_max As String = "00:05:00" 'Adapter la durée souhaitée
Private Sub Workbook_Open()
timerstart = TimeValue(Now)
lookinstatusbar
End Sub
Sub lookinstatusbar()
Dim heure1, x, y
heure1 = TimeValue(Now)
x = Application.Text(heure1 - timerstart, "[hh]:mm:ss")
minute_max = TimeValue(durée_max)
y = TimeValue(Application.Text(minute_max - TimeValue(x), "[hh]:mm:ss"))
If TimeValue(y) < TimeValue("00:01:01") Then mess = " Attention fermeture dans moins d'une minute !!!": Beep Else mess = " il reste plus que : "
If y = 0 Then fermeture: Exit Sub
DoEvents
Application.StatusBar = "------heure d'ouverture fichier : " & timerstart & " temps passé: " & x & mess & y
Application.OnTime Now + 0.00005, "ThisWorkbook.lookinstatusbar"
End Sub
Sub fermeture()
MsgBox "c'est ici que tu met ton code de fermeture"
End Sub