Reputation: 147
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?
Upvotes: 2
Views: 476
Reputation: 24458
According to my tests, both of these versions make .Status
available.
Option 1. Using pythonw.exe
instead of python.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:
import ctypes
ctypes.windll.user32.ShowWindow( ctypes.windll.kernel32.GetConsoleWindow(), 6 )
Upvotes: 1