0
我通过VBA宏启动Python。如果Python路径不好,我想要一个适当的错误消息。 我在2台不同的计算机上使用此宏,并且这两台计算机上的Python路径不一样。 2.路径是2个型动物细胞名path_Python和path_Python_2 这里是我的代码:VBA错误处理,将错误定义为错误
Function launchPython() As Boolean
Dim pathScript As String
pathScript = [path_files] + "code.py"
On Error GoTo err
Shell [path_Python].Value & " " & pathScript
launchPython = True
Exit Function
err:
On Error GoTo err2
Shell [path_Python_2].Value & " " & pathScript
launchPython = True
err2:
launchPython = False
MsgBox "Error: please check Python paths"
End Function
问题是,当2路并不好,而不是去ERR2,我有一个VBA错误信息阻塞
err:
On Error GoTo err2
Shell [path_Python_2].Value & " " & pathScript
我该如何解决这个问题? 非常感谢你
你不能使用IF语句而不是处理程序来验证路径吗? – 2013-05-07 09:24:50