Running A Python Script From Vba
Scenario: I am trying to run a python script from a vba code in excel. The code runs with no errors, but yields no results whatsoever. Code in VBA: Private Sub CommandButton1_Click
Solution 1:
Should be just like this.
RetVal = Shell("<full path to python.exe> " & "<full path to your python script>")
Or if the python script is in the same folder as the workbook, then you can try :
RetVal = Shell("<full path to python.exe> " & ActiveWorkBook.Path & "\<python script name>")
How to call python script on excel vba?
Or, try this:
Dim wsh AsObjectSet wsh = VBA.CreateObject("WScript.Shell")
Dim waitOnReturn AsBoolean: waitOnReturn = TrueDim windowStyle AsInteger: windowStyle = 1
wsh.Run "cmd.exe /S /C perl a.pl c:\temp", windowStyle, waitOnReturn
Post a Comment for "Running A Python Script From Vba"