Running macros from UiPath (macro code written in uiPath)


How can we run macros on Excel where macros are not defined in Excel? Can we write the code in UiPath and run it giving an instance of Excel?

Please suggest which activity can be used for this.

1 Like

We can run them using the activities right? even if it is not xlsm file @Pankit

Try opening the excel and use Execute Macro activity once and check if that works

Hello :grinning:

You can indeed use this activity, calling a VBA code that you wrote directly in a notepad file.
This way the note pad file is stored directly in you process folder and not in Excel or hardcoded in the studio.



In this case, we need to write the code for opening the excel and then navigating to the particular sheet, else it we need to pass the output variable of the workbook(not sure about this) @Martin_CHAUDEY

you can use an excel application scope to open the specific Excel file and put the execute macro activity to open it.
Afterwards, you can/have to pass output variable if needed (for me it’s even an opportunity)


Have a look on following as well

In case of requirement that complex datatypes are to return, maybe some constraints are to check. Activity was working for us for our scenario

This is what I mentioned in my first post :slight_smile:

And @Pankit , leaving all these aside, as mentioned by @ppr above, you can use invoke code activity to do entire thing in a single activity

1 Like