Bonsoir, j'ai plusieurs Application.Ontime dans un classeur pour le travail. Le souci c'est que je n'arrive pas à les arrêter si un autre classeur excel est ouvert dans la même session, mon code est le suivant :
Merci de votre aide
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 Option Explicit Public ProchainChrono, Départ Public Const TempsD = 60 Dim TempsRestant As Date Sub Demarre() Départ = Now + TimeSerial(0, 0, TempsD) majChrono End Sub Sub majChrono() TempsRestant = Départ - Now ProchainChrono = Now + TimeValue("00:00:01") Application.OnTime ProchainChrono, "majChrono" If UserformEtat7 = True Then With Etat7.Label8 .Caption = Format(TempsRestant, "ss") & Chr(34) End With End If End Sub Sub Arret() On Error Resume Next Application.OnTime ProchainChrono, "majChrono", , False If UserformEtat7 = True Then With Etat7.Label8 .Caption = Etat7.Label8.Caption = "60" & Chr(34) End With End If End Sub
Partager