This code will Close any application based on its windows caption
Original Author: Alex
API Declarations
Declare Function FindWindow Lib “user32” Alias “FindWindowA” (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function PostMessage Lib “user32” Alias “PostMessageA” (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const WM_CLOSE = &H10
Code
Public Function CloseApplication(byVal sAppCaption As String) As Boolean
Dim lHwnd As Long
Dim lRetVal As Long
lHwnd = FindWindow(vbNullString, sAppCaption)
If lHwnd <> 0 Then
lRetVal = PostMessage(lHwnd, WM_CLOSE, 0&, 0&)
End If
End Function