Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function ShowWindow Lib "user32" _
(ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long
Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Const SW_SHOWNORMAL = 1
Public Sub ActivateWindows(AppClass As String)
Dim WinWnd As Long
WinWnd = FindWindow(AppClass, vbNullString)
If WinWnd = 0 Then MsgBox "Couldn't find the window ...": Exit Sub
ShowWindow WinWnd, SW_SHOWNORMAL
SetForegroundWindow WinWnd
End Sub
|