I want to run an R program using VBA. I've used the following code in the sub in vba:
Dim RFile As String RFile = "C:\Users\...\MackRTrial.R" ShellExec (RFile)
and defined a ShellExec function as below. This is something I found online and runs without throwing me any error.
Public Function ShellExec(ByVal RFile As String) Dim x As Long: x = ShellExecute(0, "OPEN", strFile, "", "", 0) End Function
However, the R file MackRTrial.R is not run when I put the above code in vba. Could anyone help me to understand how to run it as well using some commands in vba itself? (If it adds any value, I'm using excel 2013 and RStudio. The R code works when run from RStudio.)