Passing Output to Result in InvokeVBS Activity

Hi all,
I am using some scripts in order to apply formulas to Excel columns, passing input variables as the column to consider, rows ecc… I need to Invoke a script which can be modified from a shared folder, in order to avoid re-opening the code and publishing, since the formulas could slightly change. Also, in case of any kind of error, I’d like to pass to UiPath the message that the script wasn’t successfully ran: I looked on the forum and it seems like it’s a question that occurred many times, but I wasn’t able to get a solution. Does anyone know how to pass an output to the Result field in InvokeVBSScript activity?

Thanks a lot!
Cheers,
Riccardo

Hi @RickyMasa ,

Welcome to UiPath Forum :bouquet:

Create vbs file “\SharedFolder\Scripts\Excel.vbs”

On Error Resume Next
Dim objExcel, objWorkbook
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("C:\Path\To\Your\File.xlsx")

If Err.Number <> 0 Then
    WScript.Echo "Error: " & Err.Description
    WScript.Quit 1
End If

--Apply your formula logic here

objWorkbook.Save
objWorkbook.Close
objExcel.Quit

WScript.Echo "Success"
WScript.Quit 0

Use the Invoke VBScript activity.
Pass the script path and parameters if needed.
Capture the result using Result in the Properties Panel.

Regards,
Arivu

@RickyMasa,

Here is how to get the output from VBS. Point to remember, it can only return String datatype output.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.