0

I can call a script in R from VBA by doing

Sub CallRScript()
    Dim myShell As Object
    Set myShell = VBA.CreateObject("WScript.Shell")

    Dim waitTillComplete As Boolean, style As Integer, path As String
    waitTillComplete = True
    style = 1
    path = "RScript C:\R_code\Scripts\ValuationFns.R"

    Call myShell.Run(path, style, waitTillComplete)
End Sub

However, the R session closes as soon as the R script is finished running. I'd like for the R session to remain open until the excel workbook is closed, an be able to run subsequent commands in the command prompt. How might I accomplish this?

Ben
  • 20,038
  • 30
  • 112
  • 189
  • 1
    http://stackoverflow.com/questions/19091746/writing-vba-code-to-call-r-script – IRTFM Oct 03 '14 at 17:11
  • 1
    http://www.omegahat.org/RDCOMServer/ (Notice that I am offering non-RScript approaches since as far as I know RScript will automatically close after completion of a task. Other approaches are offered by Dirk's `littler`.) – IRTFM Oct 03 '14 at 17:19

0 Answers0