Below macro works absolutely fine when i use it in Excel but when i copy the same macro and paste in Qlikview macro module, i keep getting error "Expected End Statement", "Macro PARSE failed,functionality was lost".
Can you please let me know how to enable this below macro in qlikview? Let me know the changes required for the below macro inorder to be compatible with Qlikview
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 = "C:\Users\username\Documents\R\R-3.5.1\bin\x64\R.exe CMD BATCH --vanilla --slave C:\Users\username\Desktop\Test.R"
errorCode = shell.Run(path, style, waitTillComplete)
If your full-path contained any space (or other special chars) the path needs to be wrapped with double-quotes. By using variables for the path the quotes needs to be included within the variable. This means something like:
path = "any path"
isn't enough because the variable path contained just: any path and no wrapping quotes around it. This means you need to specify the path-variable with something like:
path = """any path"""
path = chr(34) & "any path" & chr(34)
By relative paths I'm not sure if they could applied here - if I look on your link it seems that they suggest to build a fullpath by using the fullpath of the batch and then adjusting it appropriate.
Just doubling the quotes isn't enough - depending on the used tool and/or the kind of definition/call are 3 or 4 quotes necessary. Most often is the easiest way to a solution to skip the variable in the first step and to write the path directly in the call to check if the path and the other parameter are valid. If it worked you could replace it with a variable and maybe comment the real call and using a msgbox to check if the variable contained exactly the same content as the manual writing.