Running Alteryx via command Line from Excel VBA -- There an export log option?
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
Solved! Go to Solution.
- Labels:
- Run Command
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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 😉
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
