Hello,
I have .xlsb file which has to be converted to .xlsx file so that workflow is able to perform further logic. I have PowerShell script which I would like to embed in workflow, so that it does conversion and creates xlsx file before workflow starts execution. Also, I would like to pass file name as an argument. How can I embed code below in workflow (not import script)?
Here is my script:
$file = 'C:\Users\Test\Desktop\Example'
$xlApp = New-Object -Com Excel.Application
$xlApp.Visible = $false
$xlApp.Workbooks.Open($file + '.xlsb').SaveAs($file, [Microsoft.Office.Interop.Excel.xlFileFormat]::xlOpenXMLWorkbook)
$xlApp.Quit()
Thank you for your time.
Solved! Go to Solution.
Hi @tanja90
Why not add the script to run before the Workflow as an Event?
You can click the Canvas > Workflow - Configuration Events > Add > Run Command...
Thank you for your reply.
Here is the thing... the workflow will be upload on client's server and client will run this workflow. I'm trying to avoid uploading script to the server which is not under my control - in other words I'm avoiding submitting tickets, explanations, etc. That's why I was hoping it will be possible to embed code directly in workflow.
In case somebody else needs the script code embedded in command line, do as @PhilipMannering suggested but instead importing script do the following:
Command: powershell
Command Arguments:
"$file = 'C:\Users\Test\Desktop\Example;$xlApp = New-Object -Com Excel.Application;$xlApp.Visible = $false;$xlApp.Workbooks.Open($file + '.xlsb').SaveAs($file, [Microsoft.Office.Interop.Excel.xlFileFormat]::xlOpenXMLWorkbook);$xlApp.Quit()"
Put double quotes and separate lines with ;
Note that this is not good approach in case you will reuse the script or there is a lot of code..
I am leveraging the events feature to open a connection to an external db. Is there a way to ensure the connection stays in tact while the full workflow runs? I seem to be connecting but the workflow is not kicking off until I disable the powershell script that is running the command to enable the db connection.