Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

manipulating DOS

Status
Not open for further replies.

gomirage

Civil/Environmental
Oct 4, 2003
53
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 !

 
Replies continue below

Recommended for you

I'm sure there are fancier ways to do this but one way that might work:

In the excel workbook, create a hyperlink (right click the cell and link to the file) to your dos program, say in cell E32:

Then this macro will execute the program:

Sub Macro2()
Range("E32").Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
End Sub

If you want the dos program to change based on some values in excel, then you could write the dos program in excel with the changing cells in the "correct" position of the DOS program. Then write a macro to save the excel file as a DOS program file, e.g.

Sub Macro8()
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\mgp\Desktop\Book1.cmd", FileFormat:=xlText, _
CreateBackup:=False
End Sub

Off course now you just saved the whole workbook as a .cmd file which wasn't the intent so maybe this should be in a seperate workbook, or otherwise you have to re-save the workbook to make it a .xls file again.

If the DOS output is a .txt file then you could always use a macro to "import external data". (see the "data" pulldown)

All of these macros are easily made by just using the macro recorder.

This might not solve all of your problems but at least it may give you something to experiment with.


regards
Mogens






 
I will give it a shot eventhough i am looking for something simple. I am scared it will take me a while cause i need to get this ready tomorrow 8:00 Am :(

Thank you
 
The Shell command is the way to start a program from Excel/VBA. However, it will take you a little time to get things working, I'm afraid, so your deadline will be hard to meet...[sad]

Cheers,
Joerd

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor