Robot Task Activities - Excel Macros
The Excel Macros category has one activity, which runs a macro in an open Excel workbook.
The activity must be inside a New Excel or Attach to Excel container activity. See Excel.
Run Macro
Runs an Excel macro, optionally with arguments.

- Macro name: the name of the macro in the workbook
- Arguments: the arguments line passed to the macro; leave it empty to run the macro without arguments
- Argument delimiter: the character that splits the arguments line into separate arguments, "," by default
Each argument is passed to the macro as text. Variables are resolved in every field. The value the macro returns, if any, is written to the Task output.
In the example above, an arguments line of 1|2|3 with an argument delimiter of | passes three arguments to TestMacro.
Tips
- The workbook that contains the macro must already be open. Use an Excel Workbook Open Workbook activity before Run Macro
- The workbook must be saved in a macro-enabled format such as
.xlsm, and macros must be allowed by the Excel trust settings for the user the Robot Task runs as - Choose an Argument delimiter that cannot appear in the argument values themselves. The default comma is a poor choice when arguments contain numbers with thousands separators
- Keep DisplayAlerts cleared on the parent Excel container if the macro can raise an alert. In an unattended Job there is nobody to dismiss it, and the Task waits until it times out. A message box that the macro's own code shows is not suppressed by this setting
- Where the work can be done with the standard Excel Cell, Excel Row and Excel Column activities, prefer those over a macro. The logic then stays visible in the Robot Task instead of being hidden in the workbook