stopping or closing exe files from excel

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I can start an exe file in excel using vb code "fileOpen=shell("file
name",vbMaximizeFocus)
 
petgrub_in_excel said:
I can start an exe file in excel using vb code "fileOpen=shell("file
name",vbMaximizeFocus)

Sure, why not?
 
This demonstrates how to close a shelled app:

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))
Sleep 5000
ProcessHandle = OpenProcess(PROCESS_TERMINATE, 0, PID)
TerminateProcess ProcessHandle, 0
CloseHandle ProcessHandle
End Sub


--
Jim
message | Sorry, I forgot to add that I don't know how to close it.
|
| "Karl E. Peterson" wrote:
|
| > petgrub_in_excel wrote:
| > > I can start an exe file in excel using vb code "fileOpen=shell("file
| > > name",vbMaximizeFocus)
| >
| > Sure, why not?
| > --
| > Working Without a .NET?
| > http://classicvb.org/petition
| >
| >
| >
 

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

Back
Top