【发布时间】:2019-10-14 17:44:44
【问题描述】:
长期以来,我一直使用 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 中解决了其他问题,说明了同样的问题,但那里的解决方案对我没有帮助。例如,我已经使用了双引号,并且我已经尝试摆脱它们。
有什么想法吗?
【问题讨论】:
标签: excel vba rscript wscript.shell