Option Explicit 
 
 
 
Public Const SW_HIDE = 0 
Public Const SW_SHOWNORMAL = 1 
Public Const SW_NORMAL = 1 
Public Const SW_SHOWMINIMIZED = 2 
Public Const SW_SHOWMAXIMIZED = 3 
Public Const SW_MAXIMIZE = 3 
Public Const SW_SHOWNOACTIVATE = 4 
Public Const SW_SHOW = 5 
Public Const SW_MINIMIZE = 6 
Public Const SW_SHOWMINNOACTIVE = 7 
Public Const SW_SHOWNA = 8 
Public Const SW_RESTORE = 9 
Public Const SW_SHOWDEFAULT = 10 
Public Const SW_MAX = 10 
 
 
Declare Function GetActiveWindow Lib "user32" () As Long 
 
 
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" _ 
(ByVal hwnd As Long) As Long 
 
 
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _ 
(ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long 
 
 
Declare Function GetNextWindow Lib "user32" Alias "GetWindow" _ 
(ByVal hwnd As Long, ByVal wFlag As Long) As Long 
 
 
Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long 
Declare Function BringWindowToTop Lib "user32" (ByVal hwnd As Long) As Long 
 
Public Sub Window_Activate(strWinText As String) 
     
    Dim lngName As Long, lngLength As Long, lngWindow As Long 
    Dim strWindow As String 
     
    lngName = GetActiveWindow 
     
    Do 
         
        strWindow = Space$(512) 
         
        lngLength = GetWindowTextLength(lngName) 
         
        lngWindow = GetWindowText(lngName, strWindow, lngLength + 1) 
         
        strWindow = Left(strWindow, lngLength) 
         
        If InStr(strWindow, strWinText) > 0 Then 
             
            ShowWindow lngName, SW_SHOW 
            ShowWindow lngName, SW_SHOWMAXIMIZED 
            BringWindowToTop lngName 
            Exit Do 
        End If 
         
        lngName = GetNextWindow(lngName, 2) 
         
    Loop While lngName > 0 
     
End Sub 
 
			 
		 |