'### Constante à adapter ###
Public Const ACTION_AU_NIVEAU_FENETRE As Boolean = True 'True pour agir au niveau fenêtre sinon False
'###########################
Private Declare Function SetTimer& Lib "user32" _
(ByVal hwnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long)
Private Declare Function KillTimer& Lib "user32" _
(ByVal hwnd As Long, ByVal nIDEvent As Long)
Public NomFenetre As String
Public NoMake As Boolean
Dim OnTimer&
Private Sub LanceOnTime()
If Application.WindowState = xlMinimized Then
Call OffTimer
Application.OnTime Now + TimeValue("00:00:00"), "AfficheUserForm"
End If
End Sub
Public Sub RunTimer(Delai As Long)
If OnTimer& > 0 Then OffTimer
OnTimer& = SetTimer(0, 0, Delai, AddressOf LanceOnTime)
End Sub
Public Sub OffTimer(Optional dummy As Byte)
If OnTimer& > 0 Then
OnTimer& = KillTimer(0&, OnTimer&)
OnTimer& = 0
End If
End Sub
Public Sub myTimer(Optional dummy As Byte)
Call OffTimer
OnTimer& = 0
Call RunTimer(Delai:=0)
End Sub
Private Sub AfficheUserForm(Optional dummy As Byte)
AppActivate ThisWorkbook.Parent.Name
If Not NoMake Then UserForm1.Show
End Sub