p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Access VBA (http://p2p.wrox.com/forumdisplay.php?f=80)
-   -   Click even code for open DOS .EXE (http://p2p.wrox.com/showthread.php?t=49114)

mohiddin52 October 17th, 2006 06:23 AM

Click even code for open DOS .EXE
 
In click event it is passable to open DOS file like in E:\fpd26\foxpro.exe file

Mohamed Mohiddin
Officer

SerranoG October 18th, 2006 07:32 AM

Yes, look for help with the SHELL command.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division

mmcdonal October 18th, 2006 12:10 PM

Set objShell = CreateObject("WScript.Shell")
Set objExecObject = objShell.Exec(ping -n 3 -w 1000 " & sAddress)

This will ping the address specified in the sAddress variable.
If you want the window to stay open while the operation is running, then do this:

Set objExecObject = objShell.Exec("%comspec% /c ping -n 3 -w 1000 " & sAddress)

Or

Set objExecObject = objShell.Exec("%comspec% /k ping -n 3 -w 1000 " & sAddress)

By using %comspec%, this script will run in any Windows environment, as opposed to using "cmd.exe" or some other variant.

Does this help?



mmcdonal

mmcdonal October 18th, 2006 12:11 PM

I forgot to mention, you will need to declare objShell and objExecObject, but you don't have to type the variable. Or you can use variant.

Dim objShell
Dim objExecObject As Variant



mmcdonal

mmcdonal October 18th, 2006 12:20 PM

Its all coming back to me now...

You will also want your executable to be in your path statement.

Oooh, You can run path using the above code, then take the path as the variable, then add the path to your executable to the path variable, then pass the path variable back using set path.

Who here remembers DOS?!


'------------------

Do While Not objExecObject.StdOut.AtEndOfStream
   strText = objExecObject.StdOut.ReadAll()

   If InStr(strText, "Path") > 0 Then
        sPath = strText & ";" & "C:\Program Files\FoxPro\"
   End If
Loop

Set objExecObject = objShell.Exec(set path sPath)
Set objExecObject = objShell.Exec(foxpro.exe)

HTH
(I'll start drinking decaffeinated...)



mmcdonal


All times are GMT -4. The time now is 12:57 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.