Option Explicit
#If VBA7 Then
Private Declare PtrSafe Function GetForegroundWindow Lib "user32" () As Long
Private Declare PtrSafe Function 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) As Long
Private Declare PtrSafe Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
#Else
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare PtrSafe Function 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) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
#End If
Private hWnd As Long
Private Sub UserForm_Activate()
hWnd = GetForegroundWindow
SetWindowPos hWnd, -1, 0, 0, 0, 0, &H43 ' Pour le forcer à rester affiché.
' SetWindowPos hWnd, -2, 0, 0, 0, 0, &H43 ' Au dessus seulement des fenêtres qui ne sont pas en -1 mais sous celles ci.
SetWindowLong hWnd, -8, 0 ' Pour le rendre indépendant de toute autre fenêtre.
End Sub