我可以通过
从VBA调用R中的脚本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
但是,一旦R脚本完成运行,R会话就会关闭。我希望R会话在excel工作簿关闭之前保持打开状态,并且能够在命令提示符下运行后续命令。我怎么能做到这一点?