VBA中的r代码“运行时错误'-2147024894(80070002)':对象'IWshShell3'的方法'运行'失败”

时间:2019-10-24 11:45:30

标签: r excel vba shell

我正在尝试在VBA中运行r代码。但是我一直不断收到此错误:“运行时错误'-2147024894(80070002):对象'IWshShell3'的方法'运行'失败”

VBA:

Dim shell As Object
Dim waitTillComplete As Boolean: waitTillComplete = True
Dim style As Integer: style = 1
Dim errorCode As Integer
Dim path As String
Dim strcmd As String
Set shell = VBA.CreateObject("WScript.Shell")

    path = """C:\Program Files\R\R-3.4.4\bin\x64\RScript.exe"" ""C:\Users\joaoarodrigues\Desktop\Validatin_Tool\Control_Panel\teste_country_indicator_together\User_Choices_teste.r"""
    errorCode = shell.Run(path, style, waitTillComplete)

r:

library(openxlsx)
library(data.table)
library(plyr)
library(dplyr)
library(zip)

options(warn = 0)

dummy <- as.data.table(read.xlsx("Dummy Data_Data Model.xlsx", detectDates = T))

column1 <- unique(dummy[, column1])
column2 <- unique(dummy[, column2])

write.xlsx(list(column1,column2), file = "test.xlsx", sheetName = c("column1", "column2"))

有人知道如何解决此问题吗? 谢谢

0 个答案:

没有答案