Public Sub RunRTest()
Shell ("Rscript test.r")
End Sub
10
注意小心你的文件位置,可能需要更明确的Shell dim语句....例如 . 在VB中替换这些行
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
path = """" & Cells.Range("RhomeDir") & """ """ & Cells.Range("MyRscript") & """"
errorCode = shell.Run(path, style, waitTillComplete)
在excel中,具有命名引用RhomeDir的单元格包含文本
C:\ Program Files \ R \ R-3.2.3 \ bin \ x64 \ _script和
2 回答
注意小心你的文件位置,可能需要更明确的Shell dim语句....例如 . 在VB中替换这些行
在excel中,具有命名引用RhomeDir的单元格包含文本
C:\ Program Files \ R \ R-3.2.3 \ bin \ x64 \ _script和
MyRscript包含文本“C:/Documents/Rworkings/Rscripttest.s”
注意到unix R反斜杠和.s或.r后缀和VB用“”替换“”以在路径表达式中添加双括号(加上更多的外括号来表示字符串) . 在文件名中也有空格也不是一个好主意 .
通过搜索VBA shell找到了上面的shell命令的完整昏暗语法 .