Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default tried to execute application from VBA

Thanks, it seems like it could work, i'll try it. As a newbie, I don't
undarstand that DoEvents thing...

"Keith Willshaw" wrote in message
...

"Domagoj Vulin" wrote in message
...
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...


Try putting in a DoEvents function call between the file close
and the shell function, that should force the OS to complete its
housekeeping tasks

Also check the value returned in MyRun, it should be the
PID number of the fortran program

The main thing I'd suggest is running the program
from a batch file, this will allow you to put a PAUSE
statement in the batch file and see whats happening

ie. Create a batch file in the directory you want to use
called myprog.bat

The contents would be

test_dll.exe
PAUSE

Then run this batch file with the shell function
and it'll run in DOS prompt window that stays up

Keith




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Five plus mintues to execute CB Excel Discussion (Misc queries) 5 August 25th 08 09:48 PM
Execute C++ from Excel serine New Users to Excel 0 October 6th 05 08:48 PM
Could not execute Gary Excel Worksheet Functions 1 December 20th 04 06:20 PM
tried to execute application from VBA Tom Ogilvy Excel Programming 1 July 23rd 03 09:56 PM
tried to execute application from VBA Bill Lunney Excel Programming 0 July 23rd 03 02:05 PM


All times are GMT +1. The time now is 09:55 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"