I'm trying to create a button on Excel that runs an R script I created. This is the VBA code I tried:
Sub RunRscript()
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 = "RScript C:\R_code\Forecast.R"
errorCode = shell.Run(path, style, waitTillComplete)
End Sub
But that also returns an error -> Run-time error '-2147024894 (80070002) Automation Error.
I much appreciate any help!