Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
the shell function returns a handle. the TerminateProcess uses a handle to
kill the process. You just have to declare the definiation of the TerminateProcess function outside a routine like th code below. Private Declare Function TerminateProcess Lib "kernel32" _ (ByVal hProcess As Long, _ ByVal uExitCode As Long) As Long Sub Terminate() AppVal = Shell("C:\Program Files\SAP\saplogon.exe") lRetValue = TerminateProcess(AppVal, 0&) End Sub "John Keith" wrote: I have used the following line of code to open another application from an excel macro: AppVal = Shell("C:\Program Files\SAP\saplogon.exe") Is there something similar I can execute to close this application? John Keith |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Sun, 13 Sep 2009 00:11:01 -0700, Joel
wrote: the shell function returns a handle. the TerminateProcess uses a handle to kill the process. You just have to declare the definiation of the TerminateProcess function outside a routine like th code below. Private Declare Function TerminateProcess Lib "kernel32" _ (ByVal hProcess As Long, _ ByVal uExitCode As Long) As Long Sub Terminate() AppVal = Shell("C:\Program Files\SAP\saplogon.exe") lRetValue = TerminateProcess(AppVal, 0&) End Sub Thank you Joel, I'll do some more study as this opens some new territory for me. John Keith |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The handle of a window is the Process ID. Every window has a handle which in
VBA is HWND. To get a window you can use the parent of the window like this handle = thisworkbook.parent.hwnd You can also activate the window using either the title of the Window or the process number AppActivate title (or handle) like this AppActivate "Book1.xls" Then you can get the handle from the activewindow AppActivate "Book1" Handle = ActiveWindow.Application.Hwnd You can also use any Win32 dll to get the process number. "John Keith" wrote: On Sun, 13 Sep 2009 00:11:01 -0700, Joel wrote: the shell function returns a handle. the TerminateProcess uses a handle to kill the process. You just have to declare the definiation of the TerminateProcess function outside a routine like th code below. Private Declare Function TerminateProcess Lib "kernel32" _ (ByVal hProcess As Long, _ ByVal uExitCode As Long) As Long Sub Terminate() AppVal = Shell("C:\Program Files\SAP\saplogon.exe") lRetValue = TerminateProcess(AppVal, 0&) End Sub Thank you Joel, I'll do some more study as this opens some new territory for me. John Keith |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Sun, 13 Sep 2009 04:29:01 -0700, Joel
wrote: The handle of a window is the Process ID. Every window has a handle which in VBA is HWND. To get a window you can use the parent of the window like this handle = thisworkbook.parent.hwnd Joel, Thank you for even further detail! (I get so frustrated trying to find good VBA documentation!) John Keith |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Open , Save, and Close Macro | Excel Programming | |||
VBA Project - Open/Close with Macro | Excel Worksheet Functions | |||
macro to run on first open after save and close | Excel Programming | |||
Macro to run automatically on Open/Close | Excel Programming | |||
run macro on close & open | Excel Programming |