I call Python script from VBA. The structure of this Python script is a single function without anything else:
def myFunction():
# do stuff
return stuff_output
I know that this function works properly, because if added, print(myFunction())
generates correct output (JSON response) in command line.
In my VBA code 'RetVal` is always a 4 digit integer value. Perhaps Python function isn't even executed?
Which code and how should I fix to make it work? I would appreciate a solution which is close to my current code and without external libraries if possible.
Option Explicit
Sub RunPython()
Dim RetVal
Dim scriptPath As String
scriptPath = "C:\Users\Rychu\Desktop\python\myPythonScript.py"
RetVal = Shell("C:\Python36-32\python.exe" & " " & scriptPath, vbHide)
If RetVal = 0 Then
MsgBox "Couldn't run python script!", vbOKOnly
Else
Debug.Print RetVal
End If
End Sub