Hi All,
What I'm trying to do is run Fortran with <acronym title="visual basic for applications">VBA</acronym> code. The code below will open a DOS window and prepare Fortran to run. however, it requires me to manual press the enter key. I have tried several attempts in writing in a simulated enter key stroke in the code but, I have been unsuccessful because the active window is Excel and not the DOS window. The output data from Fortran is automatically inserted into my sheet which will allow me to run this program in a loop until certain criteria is met.
I have tried to minimize the Excel window then have the enter key simulated after a time delay again unsuccessful.
the below is part of my code that runs Fortran.
Sub Fortran_Run()
RetVal = Shell("C:\Users\admin\Desktop\sim_code\FT_simulation.exe", 1)
'Application.WindowState = xlMinimized
'lcshl.SendKeys "{ENTER}" result unsuccessful
'Application.WindowState = xlMinimized
SendKeys String:="%slc{enter}", Wait:=True
Application.Wait (Now + TimeValue("00:00:10")) results successful however the active window needs to be the DOS window that Fortran is running in.
End sub
thank you in advance any help and or advice would be appreciated.
What I'm trying to do is run Fortran with <acronym title="visual basic for applications">VBA</acronym> code. The code below will open a DOS window and prepare Fortran to run. however, it requires me to manual press the enter key. I have tried several attempts in writing in a simulated enter key stroke in the code but, I have been unsuccessful because the active window is Excel and not the DOS window. The output data from Fortran is automatically inserted into my sheet which will allow me to run this program in a loop until certain criteria is met.
I have tried to minimize the Excel window then have the enter key simulated after a time delay again unsuccessful.
the below is part of my code that runs Fortran.
Sub Fortran_Run()
RetVal = Shell("C:\Users\admin\Desktop\sim_code\FT_simulation.exe", 1)
'Application.WindowState = xlMinimized
'lcshl.SendKeys "{ENTER}" result unsuccessful
'Application.WindowState = xlMinimized
SendKeys String:="%slc{enter}", Wait:=True
Application.Wait (Now + TimeValue("00:00:10")) results successful however the active window needs to be the DOS window that Fortran is running in.
End sub
thank you in advance any help and or advice would be appreciated.