Excel shell.Run Rscript in version 3.5.0 is not working, works in 3.2.5


#1

Works:
path = """" & "C:\Program Files\R\R-3.2.5\bin\x64\Rscript" & """ """ & "C:\Box Sync\Trading\R Code Source\AssignMarginCashFlag_HP.R" & """ """ & sourcepath & """" '

After upgrade to 3.5.0 does not work, file path is correct.
path = """" & "C:\Program Files\R\R-3.5.0\bin\x64\Rscript" & """ """ & "C:\Box Sync\Trading\R Code Source\AssignMarginCashFlag_HP.R" & """ """ & sourcepath & """" '

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, sourcepath As String
sourcepath = ActiveWorkbook.path
sourcepath = sourcepath & "\Live Files"
'R code path format
sourcepath = Replace(sourcepath, "", "\")

path = """" & "C:\Program Files\R\R-3.5.0\bin\x64\Rscript" & """ """ & "C:\Box Sync\Trading\R Code Source\AssignMarginCashFlag_HP.R" & """ """ & sourcepath & """" '

errorCode = shell.Run(path, style, waitTillComplete)

Is there other settings which need changed for v3.5.0 to work?


#2

Seems to have to do with a folder, a Box Sync folder, v3.2.5 running R file however v3.5.0 does not work. If I move the R file to a local/non synced folder then both versions work running R file. Any thoughts on why v3.5.0 will not run R file from certain folders which v3.2.5 does run?
Thanks


#3

Solution: I changed the path to
path = """" & DirFile & "Rscript" & """ -e ""source('" & RCodePath & "AssignMarginCashFlag_HP.R" & "')" & """ """ & sourcepath & """" '

DirFile = "C:\Program Files\R\R-3.5.0\bin\x64"
RCodePath = "C:\Box Sync\Trading\R Code Source\"


#4

If your question's been answered (even if by you!), would you mind choosing a solution? (see FAQ below for how) It makes it a bit easier to visually navigate the site and see which questions still need help.

Thanks