我正在尝试从VBA运行python脚本,但出现运行时错误-IwshShell3失败。 下面的代码:
Sub RunPython()
Dim objShell As Object
Dim PythonExec, PythonScript As String
Set objShell = VBA.CreateObject("Wscript.Shell")
PythonExec = """C:\Users\123\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.7.exe"""
PythonScript = "C:\Users\123\Projects\Run.py"
objShell.Run PythonExec & PythonScript
End Sub
能帮我吗?
答案 0 :(得分:1)
这两个部分之间需要有一个空格:
objShell.Run PythonExec & " " & PythonScript