Public Declare PtrSafe Function SetTimer Lib "user32" (ByVal HWnd As LongPtr, ByVal nIDEvent As LongPtr, ByVal uElapse As LongPtr, ByVal lpTimerFunc As LongPtr) As LongPtr
Public Declare PtrSafe Function KillTimer Lib "user32" (ByVal HWnd As LongPtr, ByVal nIDEvent As LongPtr) As LongPtr
Public montimer As LongPtr
Sub demarre()
montimer = SetTimer(0&, 0&, 500&, AddressOf heure) 'le timer tournera et se repetera tout seul on le lance qu'une seule fois
End Sub
Sub arrete()
On Error Resume Next
KillTimer 0&, montimer 'on kill le timer
Range("A1") = "heure"
End Sub
Sub heure(ByVal HWnd As LongPtr, ByVal uMsg As LongPtr, ByVal nIDEvent As LongPtr, ByVal dwTimer As LongPtr)
Range("A1") = Time
End Sub