r-使用VBA从工作簿中的单元格中提取的路径执行Shell



我的代码直接从Excel运行R中的模型。

我想简化安装,而不是:

path = """C:Program FilesRR-4.1.1binRscript.exe"" C:UsersdiegoOneDriveOtrosEscritorioProgramacionSemanalProgramacionSemanal.R"

我想直接从同一工作簿中的单元格值中检索Rscript.exe和ProgramacionSemanal.R路径。

我试图复制我之前使用的细胞值:

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
pathRscript = Sheets("Configuracion").Range("B17")
pathForecast = Sheets("Configuracion").Range("B11")
path = """""""" & pathRscript & """""" & " " & pathForecast & """"
errorCode = shell.Run(path, 0, waitTillComplete)

这是一个";。这是我的解决方案:

path = """" & pathRscript & """" & " " & pathForecast & """"

最新更新