很长时间以来,我一直使用 vba 在 Excel 2010 和 Windows 7 中成功运行我的 r 脚本。然后我不得不使用另一台安装了 Excel 2013 和 Windows 8 的计算机。它给我以下错误:
对象“IWshShell3”的方法“运行”失败
这是在 Excel 2010 中运行的代码:
Dim shell As Object
Set shell = VBA.CreateObject("WScript.Shell")
Dim waitTillComplete As Boolean: waitTillComplete = True
Dim style As Integer: style = 0
Dim errorCode As Integer
Dim var1 As String
Dim PATH As String
var1 = Replace(Replace(ThisWorkbook.PATH, "\", "/") & "/", " ", "_z9z_")
PATH = "C:\PROGRA~1\R_App\bin\x64\RScript """ & "C:\JF\Code A\dvlp.R"" " & var1 & " " & 2500
errorCode = shell.Run(PATH, style, waitTillComplete)
相同的代码不在我提到的另一台计算机上运行。
我已经在stackoverflow中解决了其他问题,说明了同样的问题,但那里的解决方案并没有帮助我。例如,我已经使用了双引号,并且我已经尝试摆脱它们。
有任何想法吗?