Close Program

M

mark

Is it possible to close a program window, after opening it
with the shell command in vba?.
 
P

Perry

You can't ... Shell() doesn't return a handle of use.

Workarounds:
You could run through the Tasks collection like in:
Dim t As Task
For Each t In Tasks
Debug.Print t.Name
If t.Name = "bla" Then t.Close
Next

I wud favour using a couple of API calls to accurately determine
the process(thread) and really terminate the process of your choosing.

Use Google to get more info on:

Private Declare Function TerminateProcess Lib "kernel32" _
(ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long

and the accompanying other API calls needed to accurately terminate
processes/applications.

Krgrds,
Perry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top