excel vba执行R脚本

时间:2016-09-20 12:12:55

标签: excel excel-vba vba

我在excel中构建了一个UI来执行R脚本。我正在使用下面的代码。但是,我在最后一行收到错误。错误信息是:

  

方法&#39>运行'对象' IWshShell3'失败。

你能帮忙吗?

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 C:\Desktop\excel2csv.R"
    errorCode = shell.Run(path, style, waitTillComplete)
End Sub

0 个答案:

没有答案