' Put the above code in a module
Private Declare Function FindWindow _
Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) _
As Long
Private Declare Function SendMessage _
Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Long) _
As Long
Const NILL = 0&
Const WM_SYSCOMMAND = &H112
Const SC_CLOSE = &HF060&
Const WM_CLOSE = &H10
Dim lngHandle as long
Dim lngHandler as long
'Pass this function the title of the window you
'want to close
Private Sub CloseWindow(sCaption as string)
lngHandle = FindWindow(vbNullString, sCaption)
If lngHandle <> 0 Then
lngHandle1 = SendMessage(lngHandle, WM_SYSCOMMAND, SC_CLOSE, NILL)
End If
End Sub
'You can put the above code in a timer control
'so that periodically it can close any open windows
'Check the website
'It is an excellent resource for all your api needs
Regards,
Rajesh