Bonjour à toutes et à tous.
J'ai un problème avec Excel97 :
Je lance par macro un exécutable, et j'attends qu'il finisse avec un DoEvents. Il est impératif que j'attende la fin de l'exécution, car l'exe fournit un fichier de résultat dont j'ai besoin dans la suite de mon code.
Or, le DoEvents semble bloquer Excel (100% de cpu), et je suis obligé d'arrêter les macros.
Bizarement, le même code fonctionne avec excel 2002 (XP).
Encore un problème de compatibilité entre les versions !!!
Quelqu'un saurait-il comment contourner le problème du DoEvents. C'est vraiment très urgent et très important.
Merci d'avance
DA
PS : Ci dessous un extrait de mon code, pour compréhension
Sub WaitForTerm(hInstance As Long)
'================================
'Cette procédure attend la fin d'exécution d'un
'programme identifié par son handle, en
'utilisant l'API Win32
'================================
' Description des variables
'================================
Dim hProcess As Long
Dim lngRetVal As Long
Dim lngExitCode As Long
'================================
On Error GoTo errRunAppWait
' Start up the application.
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION Or SYNCHRONIZE, True, hInstance)
Do
' Attempt to retrieve the exit code, which will
' just not exist until the application has quit.
lngRetVal = GetExitCodeProcess(hProcess, lngExitCode)
'ET VALA LE PBM
DoEvents
Loop While lngExitCode = STILL_ACTIVE
EndRunAppWait:
Exit Sub
errRunAppWait:
MsgBox "Une erreur est survenue dans la procédure WaitforTerm : " & Err & " - " & Error$(), vbCritical
Resume EndRunAppWait
End Sub
'Code principal
...
' Lancement du programme ExtractProp561.EXE
lngShell = Shell(strPrgFortran, vbHide)
' Attendre que le programme soit terminé
WaitForTerm lngShell
...