Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
Community v19.6

Looks aren't everything... But the latest Community refresh looks darn good!

Learn More

Running Alteryx via command Line from Excel VBA -- There an export log option?


I'm playing around with a VBA front end in Excel and running Shell, command line code to kickoff some workflows on my desktop (no Alteryx Server yet sadly). I'm beginner level on using command line statements and syntax so I was wondering if there is a command line option to export the messages log?  If so, what's the proper syntax for it.  Also is there any sort of command line reference out there for Alteryx providing any and/or all functions, commands, syntax etc.?


Just to show my simple code:


Sub AlteryxRunCmd()
    Dim path As String
    Dim engine As String
    Dim wsh As Object
    Dim outp As Object
    Dim waitReturn As Boolean: waitReturn = True 
    Dim cmdWnd As Integer: cmdWnd = 1 
    Dim result As Long
    'Dim logPath As String
    'Set wsh to WScript.Shell object
    Set wsh = VBA.CreateObject("WScript.Shell")
    'Set your workflow path from "A2" and encapsulate in double quotes
    path = """" & Sheet1.Range("A2").Value & """"
    'Set location of Alteryx Engine unless Alteryx Engine is set as environment variable on machine
    engine = """C:\Program Files\Alteryx\bin\AlteryxEngineCmd.exe"""
    'Set logPath -- Not working at the moment
    'logPath = """" & Environ("UserProfile") & "\Desktop\LogFile.txt"""
    'Run the command line, keeping the window open in normal view and do wait for engine to finish before continuing
    result = wsh.Run(engine & " " & path, cmdWnd, waitReturn)
    'Load output from cmd to log not working at the moment
    'Set outp = wsh.stdout
    If result = 0 Then
        MsgBox "Success"
    ElseIf result = 1 Then
        MsgBox "Success but warnings"
    ElseIf result = 2 Then
        MsgBox "There was an error"
    End If
End Sub






Ideally I'd like to export a log to see why it failed or had warnings if possible.


Hi @jmstampe 


You can use the echo command within the run command to write out to a log file.


So it would look a bit like:


'Run the command line, keeping the window open in normal view and do wait for engine to finish before continuing
    result = wsh.Run(engine & " " & path & " >> MyLogPath.txt", cmdWnd, waitReturn)


But if done properly you'd assign an object to the log path  


HI @JoeS thank you for the info.  Unfortunately, I still get an error when using both the > or >>.  I tried the logic you provided and also based on variable set e.g. Dim LogPath as string = "C:\..\Logfile.txt" it's just not letting me save out.


I'll keep digging around but I may need to set up the workflow as an Analytics App instead.



Instead of using VBA, for now could you just try and run the line in a DOS window itself?


That way you may be able to see what's going on underneath easier.


It may be that you don't have the AlteryxEngineCMD licensed.


It being an Analytical App shouldn't make a difference.

Sorry for the long delay. Interestingly enough I can run it perfectly within DOS but for some reason it errors when running it through VBA. It could be something with quote placement in the string and how the shell object is recognizing it. I’ll keep digging around and post back any findings. Much appreciated, huge help.

Sure, it's worth trying with a path and file name that has no spaces, that should help with knowing if it's an issue around quotes.