ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   stopping or closing exe files from excel (https://www.excelbanter.com/excel-programming/328876-stopping-closing-exe-files-excel.html)

petgrub_in_excel

stopping or closing exe files from excel
 
I can start an exe file in excel using vb code "fileOpen=shell("file
name",vbMaximizeFocus)


Karl E. Peterson

stopping or closing exe files from excel
 
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



petgrub_in_excel

stopping or closing exe files from excel
 
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




Jim Rech

stopping or closing exe files from excel
 
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
"petgrub_in_excel" wrote in
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
|
|
|



petgrub_in_excel[_2_]

stopping or closing exe files from excel
 
works great. Thanks so much

"Jim Rech" wrote:

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
"petgrub_in_excel" wrote in
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
|
|
|




Robert_L_Ross

stopping or closing exe files from excel
 
This code doesn't work.

"Jim Rech" wrote:

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
"petgrub_in_excel" wrote in
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
|
|
|





All times are GMT +1. The time now is 05:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com