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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Manipulating DOS exe file with VBA

Status
Not open for further replies.

gomirage

Programmer
Jun 3, 2003
28
0
0
US
Hello Every,
I wonder if this is possible at all. I have a program in DOS that i want to manipulate from Excel.
The DOS exe file use excel input files. Then i have to analyse the output from excel. Since i have to change interactively the input until i have satisfactory out i want to automate this. Use excel macro to input data in the dos program, then the macro analyse the output. If satisfactory then ok. If not input the results back in the DOS exe until satisfaction.

First is there anyway to start a dos program from Excel, then how to input files in the dos exe ?

Thanks alot !
 
Hi,

The way to run a DOS app from within VBA is to use the Shell command. Syntax is Shell "Commandline"

Provided your input files can be specified as parameters with no user intervention required, then it can be done quite easily, but if you need to type things in then it isn't quite so simple.

John
 
Hello Jrbarnett,
Yeah i will need to type a word in the DOS exe after it is launched. The way the program works is:

I have the main exe file under DOS. Then when i launched it i have to in the input file i want him to execute.

Can you help me with a example code or tutorial to do this ?

So the two task i need my VBA to do is
- First launch the dos exe program from VBA
- Second write from VBA in the EXE file the name of the input file the DOS EXE should work with (i heard it should be done with sebdMessage but i am not sure how to do it).

Sounds challenging, huh ?

 
Hi,

I am not that familiar with the SendMEssage command or API functionality, but the shell command is easy:

Shell ("program.exe", vbNormal)

will run program.exe, or you can specify a full path to the program.

John
 
Yeah i get to start the program using
Shell "C:\myapplication.exe"

But i am experiancing something weird.
The myapplication.exe open but when it doesn't do what it use to do. Meanning when i input a file it can't not find it.
If i run it as i use to do (just double clicking it then it works fine) unlike when it is launched from my VBA.
Don't know what is preventing it to work when launched from VBA.
 
no - just info for other posters in case your post on the other board has any useful info - that's all!
 
A quick thought: If you usually run it from a shortcut, does it have a default path set? If so, right click on the executable, choose properties, check the path is set then change the path in the code to point to the .PIF file rather than the associated executable.

John
 
Ok,
I get it to run when launched from the macro.
Now how to pass him a sendkey or other way to input the name of an input file i want him to execute at start up without me typing the name of the input file ?

 
Hi,

Look at the SendKeys function in the VBA help, it appears to do what you want.

John
 
Hey Jrbarnett,

I've been plaing with the sendKeys but i can't get it to work properly on my program.

I want to input the the text "test.lis" and enter.

But it looks like it is taking 2 letters randomly. Either te or st or whatever. Thus, it cannot locate the input file.




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top