多年来我一直在努力寻找解决这个问题的办法。我有一些python脚本需要定期更新,希望能够使用宏来完成这项工作。现在我双击这些文件,它们通过Shell执行,没有问题。在
Sub RunPyScript()
Dim Ret_Val As Variant
Dim command As String
command = Chr(34) & "C:\Users\Jon Doe\python.exe" & Chr(34) & " " & Chr(34) & "C:\Users\Jon Doe\" & "\Roto.py" & Chr(34)
Ret_Val = Shell(command, vbNormalFocus)
End Sub
当我试图运行上面的宏时,它看起来会像双击时一样运行,但是Shell在脚本执行之前退出(我认为这是问题所在,不是肯定的)。如果有人能帮我,我真的很感激。在
顺便说一句,您可以简单地使用2个引号将引号插入字符串变量,就像我在以前的源代码中使用的那样。例如,
StrVariable=""""
给出结果"
。那么命令行的字符串是:command = """%USERPROFILE%\python.exe"" ""%USERPROFILE%\roto.py"""
结果是:
"C:\Users\John Doe\python.exe" "C:\Users\John Doe\roto.py"
相关问题 更多 >
编程相关推荐