Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Dynamic Filename

RichardAlt
8 - Asteroid

Hi Guys!

 

I'm creating a simple workflow with Run Command Tool, I need to run the macro inside the macro-enabled file. But I want my workflow to be dynamic, So I've inserted a File Browser Tool to select the ".xlsm" file and run the macro using Run Command Tool.

RichardAlt_0-1597207369893.png

 

And this is my VBScript:

dim fso: set fso = CreateObject("Scripting.FileSystemObject")
dim CurrentDirectory	
Set objExcel = CreateObject("Excel.Application")
CurrentDirectory = fso.GetAbsolutePathName(ThisWorkbook.Path)
Set objWorkbook = objExcel.Workbooks.Open(CurrentDirectory & "\*.xlsm")
objExcel.Application.Visible = True
objExcel.Application.Run "ClearContents"
objExcel.ActiveWorkbook.Save
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit
WScript.Echo "Finished."
WScript.Quit

For eg. I've selected the ".xlsm" file using File Browser Tool, How can I use that file and run the macro inside that file that I've select.

As you can see in my VBScript I've set the path and filename static. How can I change that base on the file that I've select?

2 REPLIES 2
OllieClarke
15 - Aurora
15 - Aurora

Hi @RichardAlt in order to affect the VBS script, you'll need to write it in your workflow. You can create the script with a formula tool - and then you can change the filepath in that script. Then you can output the vbs and run it in the run command tool.

 

Something like this:

OllieClarke_0-1597251993630.png

 

I've attached the workflow too. You might need to fiddle with the formula, runcmd and output to sync it with what you want, but hopefully it'll help 🙂

 

Ollie

 

RichardAlt
8 - Asteroid

@OllieClarke Thanks! It's working, I've just modified some tools.

Labels
Top Solution Authors