Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default stopping or closing exe files from excel

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default 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
|
|
|


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
|
|
|





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default 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
|
|
|



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
OPENING AND CLOSING OF EXCEL 07 FILES hot-rod-3 Excel Discussion (Misc queries) 2 July 23rd 09 12:30 AM
Excel does not delete TMP files on closing. Why? Ben Elliott Excel Discussion (Misc queries) 4 November 7th 08 01:20 PM
Excel Not Deleting .tmp Files When Closing Ron Excel Discussion (Misc queries) 1 May 29th 08 10:22 PM
Closing non EXCEL files Grace[_4_] Excel Programming 19 June 14th 04 09:11 PM


All times are GMT +1. The time now is 04:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"