×
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

Run Fortran exe from Excel.

Run Fortran exe from Excel.

Run Fortran exe from Excel.

(OP)
I have Excel sheets and small Fortran application. I made a VBA macro that saves input data for Fortran exe into a .txt file.
After that, I used Shell function in VBA macro tu execute FOR application and there is no error message, but there's neither a output TXT file that this FOR application usually creates.
I looked in the folder where are all the files (Workbook, input TXT that macro created, Fortran EXE) and there is no output TXT file. Then, if I started that Fortran.exe from windows it creates the output file from that input file that I already created using the mentioned macro.
I tried to find more about Shell function, but there is only a simple example that starts calc.exe from VBA macro.

However, here is the critical part of code:
...
Set filFile = fso.OpenTextFile(f & "\input.txt", 2, 1)
filFile.WriteLine MP
filFile.Close
Set filFile = Nothing
Set fso = Nothing
MyRun = Shell(f & "\test_dll.exe", 1)

Maybe the Shell function starts before the input.txt file is actually closed, i don't know...

Thanks in advance




RE: Run Fortran exe from Excel.

Why can't you test the running of the program with an existing file to pinpoint the problem?  Maybe you should put a test for the existence of the file before you allow the program to start.

I've done similar things using Excel to transfer input data to Word, Word for editing the input file, running a Fortran program, opening the output file in Word and transferring the data into Excel

TTFN

RE: Run Fortran exe from Excel.

Do you do anything after running the Shell method? Do you need to wait until the exe is finished before continuing your macro? There should not be a problem running the exe as you have shown, for the file will close before it's run.

DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.

RE: Run Fortran exe from Excel.

The file will close in Excel fairly quickly, but there are often delays in the OS before the file gets fully instantiated in the file directory.

TTFN

RE: Run Fortran exe from Excel.

I just had the same problem with an old dos based fortran exe.  I solved the problem by making sure the input file and fortran program were in excel's current directory.  Then i used the command shell("blah.exe") and the program ran.  The VBA code continues to run after your fortran code starts so you also have to command VBA to wait for it to finish if you need to deal with any output files.  

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