Shell cannot close an app, nor is there any way built into
VB to do that, as
far as I know.
This is code I found doing a Google search. Seems to work as an example.
Private Declare Function TerminateProcess Lib "kernel32" _
(ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Const PROCESS_TERMINATE = 1
Sub OpenClose()
Dim ProcessHandle As Long, PID As Long
PID = CLng(Shell("notepad.exe", vbNormalFocus))
Call Sleep(5000)
ProcessHandle = OpenProcess(PROCESS_TERMINATE, 0, PID)
Call TerminateProcess(ProcessHandle, 0)
Call CloseHandle(ProcessHandle) 'Clean up after ourselves
End Sub
--
Jim
"quartz" wrote in message
...
|I am using Office 2003 on Windows XP.
|
| I use Shell to open foreign apps like Acrobat and MODI, but can Shell (or
| some other command) be used to close these applications as well? If so,
how?
|
| Could someone please post example code? Thanks much in advance.