I would like to minimize the execution of the shell window and the execution of the python script with the code below:
Sub RunPython()
Dim oShell, oExec as Object
Dim sriptPath, scriptName, datas, oCmd as String
Dim weekNumber as Integer
Set oShell = CreateObject("WScript.Shell")
oCmd = "python.exe " & scriptPath & scriptName & " " & datas & " " & Str(weekNumber)
Set oExec = oShell.Exec(oCmd)
'We are waiting for the Shell script to be executed'
While oExec.Status = 0
Wend
MsgBox "Hagrid notebook update completed"
End Sub
It is imperative to keep the status information of the oExec object. I tried to insert the notion vbMinimizedFocus, but it doesn't work. Do you have an idea to solve this difficulty?
According to my tests, both of these versions make
.Statusavailable.Option 1. Using
pythonw.exeinstead ofpython.exe- it does not minimize the window, but runs it completely in the background.Option 2. You could add 2 lines at the beginning of the python script: