Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running Batch Files....

Status
Not open for further replies.

stlrain95

Programmer
Sep 21, 2001
224
US
is there a way to run a batch file from a FOXPRO form??

I have several code pieces to run word, excel, etc. But I am not quite sure if I can run a batch file?

Any help is appreciated!!

Thanks,
 
Thanks, I think.

I put the code in there and it starts to run the batch file, then just stops. When I run the batch file on it's own it works great??

Any other suggestions?
 
HI
Number of ways to do what you want.
1. Create buttons for each item and ADD CODE in its click event ..
oE=createobject("excel.application")
oE.visible = .t.

oW=createobject("word.application")
oW.visible = .t.

2. You can use ShellExecute..

DECLARE INTEGER ShellExecute IN shell32.dll ;
INTEGER hndWin, STRING cAction, STRING cFileName, ;
STRING cParams, STRING cDir, INTEGER nShowWin

You can put this code anywhere in your application, provided it is executed before you start using this code.
(Note ShellExecute is case-sensitive in the above command.)

ShellExecute() lets you "execute" any pogram, document or shortcut. At its simplest, it can be used to launch an external application. For example, this command will launch Notepad:

ShellExecute(0,"open","Notepad.Exe","","",1)

Alternatively, you could use the following code to launch Notepad and have it open a file called Readme.txt:
ShellExecute(0,"open","Readme.txt","","",1)

The following will open Word with a new file...
ShellExecute(0,"open","WinWOrd.exe","","",1)

The following will open Excel with a new file...
ShellExecute(0,"open","Excel.exe","","",1)

SO in the buttons click event , you can put the code..
DECLARE INTEGER ShellExecute IN shell32.dll ;
INTEGER hndWin, STRING cAction, STRING cFileName, ;
STRING cParams, STRING cDir, INTEGER nShowWin
ShellExecute(0,"open","Excel.exe","","",1)

Hope this helps you :) ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Could be a PATH problem, or a Bad command or file name problem, or.....
You'll probably have to be the one to determine the failure of the batch file.

Dave S.
 
Gentlemen,
The ShellExecute() worked wonderfully!!

Thank you guys for the help!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top