Option Explicit
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
Private UFhWnd As Long
Private Sub UserForm_Activate()
UFhWnd = GetForegroundWindow
SetWindowPos UFhWnd, -1, 0, 0, 0, 0, 3 ' Pour le forcer à rester affiché.
SetWindowLong UFhWnd, -8, 0 ' Pour le rendre indépendant de toute autre fenêtre.
End Sub
Private Sub CBn_Nom_Click()
SetWindowPos UFhWnd, -2, 0, 0, 0, 0, 3 ' Au dessus seulement des fenêtres qui ne sont pas en -1 mais sous celles ci.
MsgBox ActiveWorkbook.Name
SetWindowPos UFhWnd, -1, 0, 0, 0, 0, 3 ' Au premier niveau, conservant cet attribut même lorsqu'elle perd le focus.
End Sub