Running a Fortran executable from VBA

G

Guest

I'm trying to run an executable with the command
shell "C:\temp\myprogram.exe
The executable is a Fortran program, which reads from a predetermined input file and creates a text output file. The program does not ask for an input filename since it is hard-coded in the code
I can see the black DOS window opens and closes but it does not generate the output file. I do not see any error message in the DOS window, although it is possible that I just cannot catch it
If I run the executable from a DOS window or by double-clicking on it, it works
Any idea? Thanks
 
K

Kalle

try: shell "command YourProgramm"
this may give you the chance to read the output of your programm.
(in case of useing Winnt, W2k or XP change command to cmd)
 
J

jaf

Hi Fabian,
Is that the actual path or do you have some spaces in the path/filename?

Try... Shell Environ("comspec") & " /c C:\temp\myprogram.exe" vbNormalFocus

That's one line. This should cause the command window to stay open.
If there is an error message this will allow you to see it. Change the /c to
/k to close the command window when it finishes.

If there are spaces in the path you have to wrap them in quotes like...
Shell Environ("comspec") & " /c C:\" & """My Documents""" & "\myprogram.exe"
vbNormalFocus

--
John
johnf 202 at hotmail dot com


| I'm trying to run an executable with the command:
| shell "C:\temp\myprogram.exe"
| The executable is a Fortran program, which reads from a predetermined
input file and creates a text output file. The program does not ask for an
input filename since it is hard-coded in the code.
| I can see the black DOS window opens and closes but it does not generate
the output file. I do not see any error message in the DOS window, although
it is possible that I just cannot catch it.
| If I run the executable from a DOS window or by double-clicking on it, it
works.
| Any idea? Thanks.
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top