Private Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As LongPtr, ByVal uCmd As Long) As Boolean
Private Declare PtrSafe Function IsWindowVisible Lib "user32" (ByVal hwnd As LongPtr) As Boolean
Private Sub CommandButton3_Click()
Dim FWin As LongPtr
FWin = FindWindow(vbNullString, UserForm1.Caption)
If (FWin <> 0) And Not IsWindowVisible(FWin) Then
With UserForm1
.Move Application.Left + (Application.Width - .Width) / 2, _
Application.Top + (Application.Height - .Height) / 2
End With
ShowWindow FWin, 1
End If
End Sub