1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| 'patricktoulon
'a l'ouverture le userform est bloqué en premier plan
#If VBA7 Then
Private Declare PtrSafe Function SetWindowPos Lib "user32" (ByVal hwnd As LongPtr, ByVal hWndInsertAfter As LongPtr, 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 FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
#Else
Private Declare 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 FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
#End If
Private Sub UserForm_Activate()
#If VBA7 Then
Dim Handle As LongPtr
#Else
Dim Handle As Long
#End If
Application.ScreenUpdating = False
Handle = FindWindow(vbNullString, UserForm1.Caption)
SetWindowPos Handle, -1, 0&, 0&, 0&, 0&, (&H1 Or &H2 Or &H46) 'force l'userform au premier plan
End Sub |
Partager