从excel运行RScript权限被拒绝错误代码70

时间:2019-04-26 04:25:20

标签: r excel vba rscript

我正在尝试从Excel VBA运行Rscript,但收到以下错误。我尝试了不同的方法,但无法使其正常工作。有人可以帮忙吗?

Function Run_R_Script(sRApplicationPath As String, _
                        sRFilePath As String, _
                        Optional iStyle As Integer = 1, _
                        Optional bWaitTillComplete As Boolean = True) As Integer

    Dim sPath As String
    Dim shell As Object

    'Define shell object
    Set shell = VBA.CreateObject("WScript.Shell")

    'Wrap the R path with double quotations
    sPath = """" & sRApplicationPath & """"
    sPath = sPath & " "
    sPath = sPath & sRFilePath

    Run_R_Script = shell.Run(sPath, iStyle, bWaitTillComplete)
End Function

0 个答案:

没有答案