Réponse acceptée !
Bonsoir,
J'ai cherché différente façon de faire, et je suis arrivé un peu à ce que tu veux...
Dans un module mettre le code suivant :
Private Declare Sub SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
' constantes
Private Const HWND_TOPMOST = -&H1
Private Const HWND_NOTOPMOST = -&H2
Private Const HWND_BOTTOM = 1
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Function StayOnTop(Optional OnTop As Boolean)
If OnTop = True Then
Call SetWindowPos(Application.hWnd, HWND_TOPMOST, 0&, 0&, 0&, 0&, (SWP_NOSIZE Or SWP_NOMOVE)) ' Active 1er Plan
Else
Call SetWindowPos(Application.hWnd, HWND_NOTOPMOST, 0&, 0&, 0&, 0&, (SWP_NOSIZE Or SWP_NOMOVE)) ' Désactive 1er Plan
End If
End Function
=
Puis une Userform1, avec un bouton avec le code suivant :
=
Private Sub CommandButton1_Click()
Call ShowWindow(Application.hWnd, 1)
temps = Timer
Do
Loop Until Timer - temps > 3 ' attente 3 secondes
Call ShowWindow(Application.hWnd, 0)
StayOnTop True
MsgBox "Et ça marche !"
StayOnTop False
End Sub
=
Maintenant à toi de voir...
En espérant que cela te donne un bon début à étudier...
Amicalement,
Us.