(Solved) – How to detect the end of execution of a shell script in VBA Excel?

(solved)-–-how-to-detect-the-end-of-execution-of-a-shell-script-in-vba-excel?

With this code, my program runs endlessly because the status of my oExec object does not change.

sub test()
    Dim oShell As Object, oExec As Object
    Dim exePath As String, scriptPath As String, oCmd As String

    Set oShell = CreateObject("WScript.Shell")
    exePath = """C:ApplicationsPythonPython38-32python.exe"""
    scriptPath = ActiveWorkbook.Path & "Scripts"

    oCmd = "python.exe " & scriptPath & scriptName
    Set oExec = oShell.Exec(oCmd)
    'Waiting for the shell script to finish executing 
    While oExec.Status = 0
    Wend
end sub

Could you, please, help me ?

Regards

Leave a Reply

Your email address will not be published. Required fields are marked *