Run Macro
Executes a VBA macro in the Excel workbook. Supports both macros embedded in the workbook and external macro files.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing the node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
info
If ContinueOnError property is true, no error is caught when the project is executed even if the Catch node is used.
Input
- File Descriptor - File descriptor of the Excel file. This is the identifier returned by the Open Excel node.
- Macro Name - Name of the macro to execute (e.g.,
FormatData,CalculateTotals). - Macro File Path (Optional) - Optional path to an external macro file (.xla or .xlam). Leave empty to run macros from the current workbook.
Output
This node has no output.
Options
This node has no additional options.
Example
Running a macro from the current workbook:
// File Descriptor: message.excel_fd
// Macro Name: "FormatReport"
// Macro File Path: (leave empty)
// Executes the FormatReport macro from the active workbook
Running a macro from an external file:
// Macro Name: "CustomCalculations"
// Macro File Path: "C:\\Macros\\calculations.xlam"
// Opens the macro file, runs the macro, then closes it
Running macros with module names:
// If macro is in a specific module:
// Macro Name: "Module1.FormatData"
Running macros sequentially:
// 1. Run Macro
// Macro Name: "PrepareData"
// 2. Run Macro
// Macro Name: "CalculateTotals"
// 3. Run Macro
// Macro Name: "GenerateCharts"
Tips
- The Excel file must be macro-enabled (.xlsm, .xlsb) to contain macros.
- Macro names are case-sensitive in some Excel versions.
- When using Macro File Path, the file is opened, the macro runs, and the file is closed automatically.
- If the macro name doesn't include the workbook reference, it's automatically added when using an external file.
- Macros can modify the worksheet, so ensure you have backups if testing.
- VBA macros must be enabled in Excel's Trust Center for this to work.
Common Errors
| Error | Solution |
|---|---|
| Macro Name cannot be empty | Provide the name of the macro to execute |
| Macro file not found | Verify the macro file path is correct |
| Macro not found | Check the macro name spelling and ensure it exists in the workbook |
| Macros are disabled | Enable macros in Excel's Trust Center settings |
| Invalid File Descriptor | Ensure the Open Excel node was executed first |
| VBA runtime error | Check the macro code for errors |