×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

manipulating DOS

manipulating DOS

manipulating DOS

(OP)
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 !

RE: manipulating DOS

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


 



RE: manipulating DOS

(OP)
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

RE: manipulating DOS

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...

Cheers,
Joerd

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources