Use VBA code within a UiPath workflow!
- T. Francis
- Feb 14, 2023
- 1 min read
To use Visual Basic for Applications (VBA) code within a UiPath workflow, you can use the "Invoke VBA" activity. This activity allows you to run VBA macros or scripts directly from a UiPath workflow, providing a way to integrate the functionality of VBA with the automation capabilities of UiPath.

Here's how you can use the "Invoke VBA" activity in a UiPath workflow:
Add the "Invoke VBA" activity to your workflow. You can find this activity in the "UI Automation" category of the Activities Panel.
Configure the properties of the "Invoke VBA" activity. You will need to specify the VBA code that you want to run and any input arguments that are required.
Optionally, you can specify an output variable to store the result of the VBA code.
Here's a simple example to demonstrate the use of the "Invoke VBA" activity:
vbnetCopy code
'Declare a variable to store the result of the VBA codeDim result As String'Invoke the VBA code
Invoke VBA("./MyVBAProject.xlsm", "MyMacro", "Hello World!", result)
'Use the result in the rest of the workflow
Console.WriteLine(result)
In this example, the "Invoke VBA" activity runs a VBA macro named "MyMacro" from an Excel workbook file named "MyVBAProject.xlsm". The macro takes a single input argument of "Hello World!" and returns the result in the "result" variable. The value of the "result" variable is then printed to the console.
Comments