You can close ANY (and AQLL) processes via VBA if you know the 'ClassName' of the application/s that you want to close.
The code below will do it for you, and it already includes a example of the required clasname for Excel (along with a number of the more popular applications as well).
Simply make a call to the function "Close_Running_Application' passing he appropriate 'classname' as a parameter to it.
P.S. IF ( ? ) you want the code that I refer to which can allow you to determine the 'classname' of ANY application (and therefore then make it avaialable for use with the 'Close_Running_Application'), post back and I will post THAT code as well.
CODE
Option Compare Database
Option Explicit
Private Const WM_CLOSE = &H10
Private Const INFINITE = &HFFFFFFFF
Private Declare Function apiPostMessage _
Lib "user32" Alias "PostMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) _
As Long
Private Declare Function apiFindWindow _
Lib "user32" Alias "FindWindowA" _
(ByVal lpClassname As String, _
ByVal lpWindowName As String) _
As Long
Private Declare Function apiWaitForSingleObject _
Lib "kernel32" Alias "WaitForSingleObject" _
(ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) _
As Long
Private Declare Function apiIsWindow _
Lib "user32" Alias "IsWindow" _
(ByVal hwnd As Long) _
As Long
Private Declare Function apiGetWindowThreadProcessId _
Lib "user32" Alias "GetWindowThreadProcessId" _
(ByVal hwnd As Long, _
lpdwProcessID As Long) _
As Long
Function Close_Running_Application(lpClassname As String, _
Optional lpWindowName As String = vbNullString) _
As Boolean
'
' Can close any application that is running. To do it you have to KNOW what the actual ClassName
' of the actual application is.
' This can be determined by running the function "Show_Running_Application" from the Immediate Window
' and then passing that to THIS function
'
'Usage Examples:
' To close an application:
' ? Close_Running_Application("SciCalc") ' Calculator
' ? Close_Running_Application("XLMAIN") ' ALL versions of Excel, any spreadsheet
' ? Close_Running_Application("rctrl_renwnd32" ' Outlook XP
' ? Close_Running_Application("ExploreWClass") ' Windows Explorer
' ? Close_Running_Application("IEFrame") ' Internet Explorer
' ? Close_Running_Application("EXCLICKYES_WND") ' ClickYes
' ? Close_Running_Application("ShockwaveFlash") ' Flash
'
' ------------------------------------------------------------------------------------
' Media Players:
' ? Close_Running_Application("WMPlayerApp") ' Windows Media Player
' ? Close_Running_Application("Media Player 2") ' Windows Media Player 2
' ? Close_Running_Application("MediaPlayerClassicW") ' Windows Media Player CLASSIC
' ? Close_Running_Application("STUDIO") ' WinAMP3
' ? Close_Running_Application("QWidget") ' DivX Player
' ? Close_Running_Application("WinDVDClass") ' WinFastDVD
' ? Close_Running_Application("MMJB:MAINWND") ' MUSICMATCH JukeBox
' ? Close_Running_Application("RadioToolBox v1.x") ' Radio Toolbox
' ? Close_Running_Application("CyberLink Video Window Class") ' PowerDVD
'
' ------------------------------------------------------------------------------------
' To close a specific file running under an application:
' ? Close_Running_Application("XLMAIN","Microsoft Excel - MySheet.xls") ' ALL versions of Excel,specific spreadsheet
Dim lngRet As Long, hwnd As Long, pID As Long
Close_Running_Application = False
hwnd = apiFindWindow(lpClassname, lpWindowName)
If (hwnd) Then
lngRet = apiPostMessage(hwnd, WM_CLOSE, 0, ByVal 0&)
Call apiGetWindowThreadProcessId(hwnd, pID)
Call apiWaitForSingleObject(pID, INFINITE)
Close_Running_Application = Not (apiIsWindow(hwnd) = 0)
Close_Running_Application = True
End If
End Function
'************* Code End ***************
Function Close_ALL_Occurrences_Of_Application(lpClassname As String) As Boolean
Dim bolApplnClosed As Boolean
Dim MaxCloseCount As Integer
Do Until MaxCloseCount = 25
MaxCloseCount = MaxCloseCount + 1
bolApplnClosed = Close_Running_Application(lpClassname)
Loop
End Function