How To Run Fortran.exe using Excel

  • Context: Fortran 
  • Thread starter Thread starter khazarhayat
  • Start date Start date
  • Tags Tags
    Excel
Click For Summary
SUMMARY

The discussion focuses on executing a Fortran executable (fortran.exe), compiled with Intel Visual Fortran Compiler 10.1.24 and Visual Studio 2005, from Excel 2010 using the Shell function. Although the Shell function runs fortran.exe, it fails to generate the output.dat file, unlike when executed directly. The user has attempted various troubleshooting methods, including recompiling the program and adjusting Excel macro security settings, but has not found a solution. The issue appears to be related to the execution environment set by Excel.

PREREQUISITES
  • Understanding of Fortran programming and compilation using Intel Visual Fortran Compiler 10.1.24
  • Familiarity with Excel 2010 and its Shell function
  • Basic knowledge of file handling in DOS environments
  • Awareness of VBA (Visual Basic for Applications) for potential automation
NEXT STEPS
  • Investigate the use of the Shell function with parameters that ensure the Fortran executable waits for completion
  • Explore the possibility of using a Fortran DLL to interface with Excel
  • Research debugging techniques for Excel macros to identify execution issues
  • Look into alternative methods for executing external programs from Excel, such as using VBA's CreateObject method
USEFUL FOR

This discussion is beneficial for software developers, particularly those working with Fortran and Excel integration, as well as anyone troubleshooting executable file execution issues within Excel environments.

khazarhayat
Messages
2
Reaction score
0
Hello everybody,

I have a fortran.exe (compiled using intel visual fortan comipler 10.1.24 and VS 2005) which takes an input.dat file and generates output.dat.

Currently, I am trying to control fortran.exe execution with excel 2010 shell function. But it is not working properly.

The Shell function syntax is correct, it does run fortran.exe and DOS window can be seen. But fortran.exe ends prematurely without generating output.dat file. However, In case of double-clicking fortran.exe, it runs and reads input.dat and generate output.dat properly.

I have spent several days on this problem. I have recompile program, relaxed excel-marco security setting etc, but in vain.There are similar posts on web describing such problem, but no one clearly described the solution.

Surprisingly, using same shell function i can successfully run a java.exe file.

Any kind of comments, suggestion, advice regarding above problem will be warmly welcomed.
 
Technology news on Phys.org
Disclaimer: don't use excel much, don't know VBA, don't do much DOS.

Debugging/testing ideas:
are all the files in the same directory? including the fortran exe?
is the command to start the fortran exe instructed to wait for it to finish?
google returned a few hints about calling fortran DLLs from excel, is this of no use to you?
 

Similar threads

  • · Replies 9 ·
Replies
9
Views
16K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
Replies
15
Views
11K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 1 ·
Replies
1
Views
6K
  • · Replies 54 ·
2
Replies
54
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K