Рассмотрите возможность использования VBA Shell StdOut
для захвата потока выходных линий. Обязательно иметь Python скрипт печати на экран значение:
Python
...
print(outputval)
VBA(s
ниже будет строка вывода)
Public Sub PythonOutput()
Dim oShell As Object, oCmd As String
Dim oExec As Object, oOutput As Object
Dim arg As Variant
Dim s As String, sLine As String
Set oShell = CreateObject("WScript.Shell")
arg = "somevalue"
oCmd = "python ""C:\Path\To\Python\Script.py""" & " " & arg
Set oExec = oShell.Exec(oCmd)
Set oOutput = oExec.StdOut
While Not oOutput.AtEndOfStream
sLine = oOutput.ReadLine
If sLine <> "" Then s = s & sLine & vbNewLine
Wend
Debug.Print s
Set oOutput = Nothing: Set oExec = Nothing
Set oShell = Nothing
End Sub
Кредит
Сценарий, заимствованный из @bburns.km, не принимаемый ответ, из этого SO post