Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Is there any way to start (and later quit) an EXE file.
I am trying to start the following program when I activate a page."C:\Program
Files\RealVNC\vncviewer.exe" -listen The purpose is to use a barcode scanner and load data into excel. The above program has to be resident in the Tray for the scanner to load data into a data page. Later I would like to unload or quit the EXE file to let excel get control back. Any thoughts would be greatly appreciated. Thanks Steve |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Is there any way to start (and later quit) an EXE file.
Steve,
You can use the Shell function to launch an executable file but you don't retain control of it which means you can't shut it down from within your VBA code. Typically, you would use the Windows API to shut down the application which is somewhat cumbersome but not impossible. If you're not using this on any systems with Win98 or earlier, there is an option using WMI. Basically, you launch the application and capture the process ID value at the same time and then use a second WMI routine to kill the process with that PID. Let us know if this situation applies. Steve Yandl "Steve" wrote in message ... I am trying to start the following program when I activate a page."C:\Program Files\RealVNC\vncviewer.exe" -listen The purpose is to use a barcode scanner and load data into excel. The above program has to be resident in the Tray for the scanner to load data into a data page. Later I would like to unload or quit the EXE file to let excel get control back. Any thoughts would be greatly appreciated. Thanks Steve |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Is there any way to start (and later quit) an EXE file.
Thanks Steve
We are using WinXP. The reason I would like to quit at some point is to regain complete control of XP and lose barcode scanner control. We then use excel to load the data into a database that cannot at this point be controlled by the Scanner. We are using VNC.exe as the executable, which puts the top left corner of excel on the scanner screen. "Steve Yandl" wrote: Steve, You can use the Shell function to launch an executable file but you don't retain control of it which means you can't shut it down from within your VBA code. Typically, you would use the Windows API to shut down the application which is somewhat cumbersome but not impossible. If you're not using this on any systems with Win98 or earlier, there is an option using WMI. Basically, you launch the application and capture the process ID value at the same time and then use a second WMI routine to kill the process with that PID. Let us know if this situation applies. Steve Yandl "Steve" wrote in message ... I am trying to start the following program when I activate a page."C:\Program Files\RealVNC\vncviewer.exe" -listen The purpose is to use a barcode scanner and load data into excel. The above program has to be resident in the Tray for the scanner to load data into a data page. Later I would like to unload or quit the EXE file to let excel get control back. Any thoughts would be greatly appreciated. Thanks Steve |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Is there any way to start (and later quit) an EXE file.
Steve,
Since you're running Windows XP, you can use WMI which I think is simpler than setting up to use Windows API. Of course, you might open the VBE and check under 'Tools References' to see if you might not have the ability to control some of the objects associated with VNC.exe. Anyway, the subroutines below should get you going. Paste the publicly declared variable as well as the two subroutines into a module after opening VBE (Alt plus F11). Since I didn't have VNC.exe to test on, the subroutine is set to launch a new notepad.exe process when you run the subroutine, LaunchApp(), and then terminate that process when you run QuitApp(). After you test with notepad, go into the LaunchApp() subroutine and edit the line beginning with "strApp =" to point to your exe rather than notepad. Since VNC.exe probably isn't in your system path, you will want to include the full path statement along with the file name. _________________________________________ Public intProcessID As Integer Sub LaunchApp() strApp = "Notepad.exe" Set objProcess = GetObject("winmgmts:root\cimv2:Win32_Process") errReturn = objProcess.Create(strApp, Null, Null, intProcessID) Set objProcess = Nothing End Sub Sub QuitApp() Dim objWMIService Dim colProcessList Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set colProcessList = objWMIService.ExecQuery _ ("Select * from Win32_Process Where ProcessID = " & intProcessID & "") For Each objProcess In colProcessList objProcess.Terminate Next End Sub _________________________________________ Steve "Steve" wrote in message ... Thanks Steve We are using WinXP. The reason I would like to quit at some point is to regain complete control of XP and lose barcode scanner control. We then use excel to load the data into a database that cannot at this point be controlled by the Scanner. We are using VNC.exe as the executable, which puts the top left corner of excel on the scanner screen. "Steve Yandl" wrote: Steve, You can use the Shell function to launch an executable file but you don't retain control of it which means you can't shut it down from within your VBA code. Typically, you would use the Windows API to shut down the application which is somewhat cumbersome but not impossible. If you're not using this on any systems with Win98 or earlier, there is an option using WMI. Basically, you launch the application and capture the process ID value at the same time and then use a second WMI routine to kill the process with that PID. Let us know if this situation applies. Steve Yandl "Steve" wrote in message ... I am trying to start the following program when I activate a page."C:\Program Files\RealVNC\vncviewer.exe" -listen The purpose is to use a barcode scanner and load data into excel. The above program has to be resident in the Tray for the scanner to load data into a data page. Later I would like to unload or quit the EXE file to let excel get control back. Any thoughts would be greatly appreciated. Thanks Steve |
#5
Posted to microsoft.public.excel.misc
|
|||
|
|||
Is there any way to start (and later quit) an EXE file.
Fantastic Steve. really appreciate your help. Will try it out tomorrow. I
still have to get VNC up and running to give it the full test. Thanks again! "Steve Yandl" wrote: Steve, Since you're running Windows XP, you can use WMI which I think is simpler than setting up to use Windows API. Of course, you might open the VBE and check under 'Tools References' to see if you might not have the ability to control some of the objects associated with VNC.exe. Anyway, the subroutines below should get you going. Paste the publicly declared variable as well as the two subroutines into a module after opening VBE (Alt plus F11). Since I didn't have VNC.exe to test on, the subroutine is set to launch a new notepad.exe process when you run the subroutine, LaunchApp(), and then terminate that process when you run QuitApp(). After you test with notepad, go into the LaunchApp() subroutine and edit the line beginning with "strApp =" to point to your exe rather than notepad. Since VNC.exe probably isn't in your system path, you will want to include the full path statement along with the file name. _________________________________________ Public intProcessID As Integer Sub LaunchApp() strApp = "Notepad.exe" Set objProcess = GetObject("winmgmts:root\cimv2:Win32_Process") errReturn = objProcess.Create(strApp, Null, Null, intProcessID) Set objProcess = Nothing End Sub Sub QuitApp() Dim objWMIService Dim colProcessList Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set colProcessList = objWMIService.ExecQuery _ ("Select * from Win32_Process Where ProcessID = " & intProcessID & "") For Each objProcess In colProcessList objProcess.Terminate Next End Sub _________________________________________ Steve "Steve" wrote in message ... Thanks Steve We are using WinXP. The reason I would like to quit at some point is to regain complete control of XP and lose barcode scanner control. We then use excel to load the data into a database that cannot at this point be controlled by the Scanner. We are using VNC.exe as the executable, which puts the top left corner of excel on the scanner screen. "Steve Yandl" wrote: Steve, You can use the Shell function to launch an executable file but you don't retain control of it which means you can't shut it down from within your VBA code. Typically, you would use the Windows API to shut down the application which is somewhat cumbersome but not impossible. If you're not using this on any systems with Win98 or earlier, there is an option using WMI. Basically, you launch the application and capture the process ID value at the same time and then use a second WMI routine to kill the process with that PID. Let us know if this situation applies. Steve Yandl "Steve" wrote in message ... I am trying to start the following program when I activate a page."C:\Program Files\RealVNC\vncviewer.exe" -listen The purpose is to use a barcode scanner and load data into excel. The above program has to be resident in the Tray for the scanner to load data into a data page. Later I would like to unload or quit the EXE file to let excel get control back. Any thoughts would be greatly appreciated. Thanks Steve |
#6
Posted to microsoft.public.excel.misc
|
|||
|
|||
Is there any way to start (and later quit) an EXE file.
Hi Steve
VNC loads fine but getting an error when trying to unload the EXE in line "For Each objProcess In colProcessList" and it won't terminate. Is there also a way to avoid the first macro trying to load the EXE a second time? I am using the Worksheet Activate and Worksheet Deactivate for the load and unload of the EXE. Thanks a bunch "Steve" wrote: Fantastic Steve. really appreciate your help. Will try it out tomorrow. I still have to get VNC up and running to give it the full test. Thanks again! "Steve Yandl" wrote: Steve, Since you're running Windows XP, you can use WMI which I think is simpler than setting up to use Windows API. Of course, you might open the VBE and check under 'Tools References' to see if you might not have the ability to control some of the objects associated with VNC.exe. Anyway, the subroutines below should get you going. Paste the publicly declared variable as well as the two subroutines into a module after opening VBE (Alt plus F11). Since I didn't have VNC.exe to test on, the subroutine is set to launch a new notepad.exe process when you run the subroutine, LaunchApp(), and then terminate that process when you run QuitApp(). After you test with notepad, go into the LaunchApp() subroutine and edit the line beginning with "strApp =" to point to your exe rather than notepad. Since VNC.exe probably isn't in your system path, you will want to include the full path statement along with the file name. _________________________________________ Public intProcessID As Integer Sub LaunchApp() strApp = "Notepad.exe" Set objProcess = GetObject("winmgmts:root\cimv2:Win32_Process") errReturn = objProcess.Create(strApp, Null, Null, intProcessID) Set objProcess = Nothing End Sub Sub QuitApp() Dim objWMIService Dim colProcessList Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set colProcessList = objWMIService.ExecQuery _ ("Select * from Win32_Process Where ProcessID = " & intProcessID & "") For Each objProcess In colProcessList objProcess.Terminate Next End Sub _________________________________________ Steve "Steve" wrote in message ... Thanks Steve We are using WinXP. The reason I would like to quit at some point is to regain complete control of XP and lose barcode scanner control. We then use excel to load the data into a database that cannot at this point be controlled by the Scanner. We are using VNC.exe as the executable, which puts the top left corner of excel on the scanner screen. "Steve Yandl" wrote: Steve, You can use the Shell function to launch an executable file but you don't retain control of it which means you can't shut it down from within your VBA code. Typically, you would use the Windows API to shut down the application which is somewhat cumbersome but not impossible. If you're not using this on any systems with Win98 or earlier, there is an option using WMI. Basically, you launch the application and capture the process ID value at the same time and then use a second WMI routine to kill the process with that PID. Let us know if this situation applies. Steve Yandl "Steve" wrote in message ... I am trying to start the following program when I activate a page."C:\Program Files\RealVNC\vncviewer.exe" -listen The purpose is to use a barcode scanner and load data into excel. The above program has to be resident in the Tray for the scanner to load data into a data page. Later I would like to unload or quit the EXE file to let excel get control back. Any thoughts would be greatly appreciated. Thanks Steve |
#7
Posted to microsoft.public.excel.misc
|
|||
|
|||
Is there any way to start (and later quit) an EXE file.
Steve,
I'll have to do a few experiments later today. I think the problem is that the value of the variable, intProcessID isn't being retained because you placed the procedures in separate event driven procedures. We can modify the QuitApp subroutine so that it will terminate any process named "VNC.exe" which would probably work fine since it isn't likely you're running any other instances of VNC.exe (if you use the process ID instead of the process name, you're able to work with a single instance of the application, even while other instances are running. A similar loop could be run to set some boolean variable based on whether or not any process named VNC.exe was running and use the outcome to determine whether the application got started. As a start, do a Ctrl-Alt-Del and check the process list while VNC.exe is running so we can be certain of its process name (is it vnc.exe, VNC.EXE, or something else?) Steve "Steve" wrote in message ... Hi Steve VNC loads fine but getting an error when trying to unload the EXE in line "For Each objProcess In colProcessList" and it won't terminate. Is there also a way to avoid the first macro trying to load the EXE a second time? I am using the Worksheet Activate and Worksheet Deactivate for the load and unload of the EXE. Thanks a bunch "Steve" wrote: Fantastic Steve. really appreciate your help. Will try it out tomorrow. I still have to get VNC up and running to give it the full test. Thanks again! "Steve Yandl" wrote: Steve, Since you're running Windows XP, you can use WMI which I think is simpler than setting up to use Windows API. Of course, you might open the VBE and check under 'Tools References' to see if you might not have the ability to control some of the objects associated with VNC.exe. Anyway, the subroutines below should get you going. Paste the publicly declared variable as well as the two subroutines into a module after opening VBE (Alt plus F11). Since I didn't have VNC.exe to test on, the subroutine is set to launch a new notepad.exe process when you run the subroutine, LaunchApp(), and then terminate that process when you run QuitApp(). After you test with notepad, go into the LaunchApp() subroutine and edit the line beginning with "strApp =" to point to your exe rather than notepad. Since VNC.exe probably isn't in your system path, you will want to include the full path statement along with the file name. _________________________________________ Public intProcessID As Integer Sub LaunchApp() strApp = "Notepad.exe" Set objProcess = GetObject("winmgmts:root\cimv2:Win32_Process") errReturn = objProcess.Create(strApp, Null, Null, intProcessID) Set objProcess = Nothing End Sub Sub QuitApp() Dim objWMIService Dim colProcessList Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set colProcessList = objWMIService.ExecQuery _ ("Select * from Win32_Process Where ProcessID = " & intProcessID & "") For Each objProcess In colProcessList objProcess.Terminate Next End Sub _________________________________________ Steve "Steve" wrote in message ... Thanks Steve We are using WinXP. The reason I would like to quit at some point is to regain complete control of XP and lose barcode scanner control. We then use excel to load the data into a database that cannot at this point be controlled by the Scanner. We are using VNC.exe as the executable, which puts the top left corner of excel on the scanner screen. "Steve Yandl" wrote: Steve, You can use the Shell function to launch an executable file but you don't retain control of it which means you can't shut it down from within your VBA code. Typically, you would use the Windows API to shut down the application which is somewhat cumbersome but not impossible. If you're not using this on any systems with Win98 or earlier, there is an option using WMI. Basically, you launch the application and capture the process ID value at the same time and then use a second WMI routine to kill the process with that PID. Let us know if this situation applies. Steve Yandl "Steve" wrote in message ... I am trying to start the following program when I activate a page."C:\Program Files\RealVNC\vncviewer.exe" -listen The purpose is to use a barcode scanner and load data into excel. The above program has to be resident in the Tray for the scanner to load data into a data page. Later I would like to unload or quit the EXE file to let excel get control back. Any thoughts would be greatly appreciated. Thanks Steve |
#8
Posted to microsoft.public.excel.misc
|
|||
|
|||
Is there any way to start (and later quit) an EXE file.
Steve,
Try this alternate approach below. Inside the query lines, replace Notepad.exe with whatever appears in your process list for VNC.exe when it's running (likely VNC.exe). Where I have the line: Shell "Notepad.exe" you will need to replace Notepad.exe with the full path and file name for VNC.exe (don't forget to retain the quote marks). ______________________________________ Sub LaunchApp() Dim objWMIService Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set colItems = objWMIService.ExecQuery _ ("Select * From Win32_Process Where Name = 'Notepad.exe'") If colItems.Count < 1 Then Shell "Notepad.exe" End If Set objWMIService = Nothing End Sub Sub QuitApp() Dim objWMIService Dim colProcessList Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set colProcessList = objWMIService.ExecQuery _ ("Select * from Win32_Process Where Name = 'Notepad.exe'") For Each objProcess In colProcessList objProcess.Terminate Next Set objWMIService = Nothing End Sub ________________________________________ Steve "Steve" wrote in message ... Hi Steve VNC loads fine but getting an error when trying to unload the EXE in line "For Each objProcess In colProcessList" and it won't terminate. Is there also a way to avoid the first macro trying to load the EXE a second time? I am using the Worksheet Activate and Worksheet Deactivate for the load and unload of the EXE. Thanks a bunch "Steve" wrote: Fantastic Steve. really appreciate your help. Will try it out tomorrow. I still have to get VNC up and running to give it the full test. Thanks again! "Steve Yandl" wrote: Steve, Since you're running Windows XP, you can use WMI which I think is simpler than setting up to use Windows API. Of course, you might open the VBE and check under 'Tools References' to see if you might not have the ability to control some of the objects associated with VNC.exe. Anyway, the subroutines below should get you going. Paste the publicly declared variable as well as the two subroutines into a module after opening VBE (Alt plus F11). Since I didn't have VNC.exe to test on, the subroutine is set to launch a new notepad.exe process when you run the subroutine, LaunchApp(), and then terminate that process when you run QuitApp(). After you test with notepad, go into the LaunchApp() subroutine and edit the line beginning with "strApp =" to point to your exe rather than notepad. Since VNC.exe probably isn't in your system path, you will want to include the full path statement along with the file name. _________________________________________ Public intProcessID As Integer Sub LaunchApp() strApp = "Notepad.exe" Set objProcess = GetObject("winmgmts:root\cimv2:Win32_Process") errReturn = objProcess.Create(strApp, Null, Null, intProcessID) Set objProcess = Nothing End Sub Sub QuitApp() Dim objWMIService Dim colProcessList Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set colProcessList = objWMIService.ExecQuery _ ("Select * from Win32_Process Where ProcessID = " & intProcessID & "") For Each objProcess In colProcessList objProcess.Terminate Next End Sub _________________________________________ Steve "Steve" wrote in message ... Thanks Steve We are using WinXP. The reason I would like to quit at some point is to regain complete control of XP and lose barcode scanner control. We then use excel to load the data into a database that cannot at this point be controlled by the Scanner. We are using VNC.exe as the executable, which puts the top left corner of excel on the scanner screen. "Steve Yandl" wrote: Steve, You can use the Shell function to launch an executable file but you don't retain control of it which means you can't shut it down from within your VBA code. Typically, you would use the Windows API to shut down the application which is somewhat cumbersome but not impossible. If you're not using this on any systems with Win98 or earlier, there is an option using WMI. Basically, you launch the application and capture the process ID value at the same time and then use a second WMI routine to kill the process with that PID. Let us know if this situation applies. Steve Yandl "Steve" wrote in message ... I am trying to start the following program when I activate a page."C:\Program Files\RealVNC\vncviewer.exe" -listen The purpose is to use a barcode scanner and load data into excel. The above program has to be resident in the Tray for the scanner to load data into a data page. Later I would like to unload or quit the EXE file to let excel get control back. Any thoughts would be greatly appreciated. Thanks Steve |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Delayed start-up due to xlb file of other version? | Excel Discussion (Misc queries) | |||
hidden file at start up | Excel Discussion (Misc queries) | |||
How do I start a new application when I open a file? | Excel Discussion (Misc queries) | |||
Can't start Excel based on File Type | Excel Discussion (Misc queries) | |||
double click a xls file and start Excel but without the file | Excel Discussion (Misc queries) |