我已经通过几种解决方案搜索了同样的问题,但我的代码仍然无法运行。确保我的文件路径中没有空格,并且仍然有三重引号可以确保。我得到运行宏的对象'IWshShell3'失败'的错误'Method'Run'。我在这里可能会错过什么?在Excel VBA中运行RScript时出错
代码:
Sub RunRscript()
Dim shell As Object
Set shell = VBA.CreateObject("WScript.Shell")
Dim waitTillComplete As Boolean: waitTillComplete = True
Dim style As Integer: style = 1
Dim errorCode As Integer
Dim path As String
path = "RScript ""G:\structureshouston\Kocian\hello.R"""
errorCode = shell.Run(path, style, waitTillComplete)
End Sub
你真的可以从命令行运行Rscript吗?它是否可以通过你的Path环境变量访问? – MrFlick
错误输出后是什么'errorCode'? – Jeeped
与'rscript.exe'关联的'.r'文件扩展名是什么?你可以省略程序并通过关联运行它吗? – Jeeped