View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tae-Yun Park[_2_] Tae-Yun Park[_2_] is offline
external usenet poster
 
Posts: 1
Default works on 2000, but not on XP

Hi all:

I'm in trouble finding why the following code works on 2000, but does not
work on XP:

---------------------------------------------------------------

Public Sub DoFortran1(Optional FakeArg As Integer)

Dim Program, i

Dim TaskID As Long

Dim hProc As Long

Dim lExitCode As Long

' Executing External Fortran Procedure with detecting process status
ACCESS_TYPE = &H400 STILL_ACTIVE = &H103&

Program = ThisWorkbook.Path & "\Lab_Sim.exe"

'On Error Resume Next

TaskID = Shell(Program, 0) 'Launching Fortran program

hProc = OpenProcess(ACCESS_TYPE, False, TaskID) 'Get the process handle

If Err < 0 Then

MsgBox "Cannot Start Fortran program " & Program, vbCritical, "Error"

Exit Sub

End If

Do ' Looping to detect the program status to the end

Call GetExitCodeProcess(hProc, lExitCode)

DoEvents

UpdateProgress

Loop While lExitCode = STILL_ACTIVE

MsgBox "Fortran based calculation completed"

Unload Progress_FORTRAN

End Sub

----------------------------------------------------------------------

It is a VBA coding in Excel to execute a custom program in FORTRAN called
"Lab_Sim.exe". Anyone can tell me why this works on 2000, but not on XP??

Thanks in advance.

TYP