Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 17th, 2006, 06:23 AM
Authorized User
 
Join Date: Dec 2003
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
__________________
Mohamed Mohiddin
Officer
 
Old October 18th, 2006, 07:32 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Yes, look for help with the SHELL command.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old October 18th, 2006, 12:10 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

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
 
Old October 18th, 2006, 12:11 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

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
 
Old October 18th, 2006, 12:20 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Right click to Open a menu peace2007 Ajax 2 November 5th, 2007 02:25 AM
how to open new window on button click nittin14 ASP.NET 1.0 and 1.1 Basics 8 April 28th, 2007 12:13 AM
How open a DOS-box from Access 2003 cvandijk Access VBA 1 January 31st, 2005 10:02 AM
On click open a report vita Access 4 October 2nd, 2003 06:47 AM
Writing VBA Code for DOS Commands dgarcia1128 Access VBA 7 August 3rd, 2003 08:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.