'Shell using path pulled from cell in workbook using VBA
My code runs a model in R directly from Excel.
I want to simplify installation so instead of:
path = """C:\Program Files\R\R-4.1.1\bin\Rscript.exe"" C:\Users\diego\OneDrive\Otros\Escritorio\ProgramacionSemanal\ProgramacionSemanal.R"
I want to retrieve Rscript.exe and ProgramacionSemanal.R path directly from cell values in the same workbook.
I tried to replicate what I had before using the cell values:
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)
Solution 1:[1]
It was a matter of "". Here's my solution:
path = """" & pathRscript & """" & " " & pathForecast & """"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Diego |