I would like to run an R script I have named "iterate.R" from an MS Access module via a command button on a form.
I found the following code on StackOverflow, but something is wrong when I substitute my path.
Link
Thank you.
I found the following code on StackOverflow, but something is wrong when I substitute my path.
Link
Code:
Sub RunRscript()
Dim shell As Object
Dim path As String
Dim waitTillComplete As Boolean: waitTillComplete = True
Dim style As Integer: style = 1
Dim errorCode As Integer
' comment out: DoCmd.TransferText acExportDelim, , "qryToExport", "C:\Path\To\CSV.csv"
Set shell = VBA.CreateObject("WScript.Shell")
path = "RScript ""C:\Path\To\R\script.R"""
errorCode = shell.Run(path, style, waitTillComplete)
Set shell = Nothing
End Sub
Thank you.