How is your experience with the OutSystems Community?
excelmacrorunner
Reactive icon

ExcelMacroRunner

Stable version 1.0.0 (Compatible with OutSystems 11)
Uploaded
 on 24 June 2025
 by 
0.0
 (0 ratings)
excelmacrorunner

ExcelMacroRunner

Documentation
1.0.0

Main Use Case

  • Automate Excel processes that are only available via VBA macros.
  • Trigger advanced calculations, formatting, or Excel-based workflows from OutSystems.
  • Seamlessly integrate legacy Excel automation logic into modern web applications.


How It Works

The extension uses Microsoft.Office.Interop.Excel to:

  • Open an Excel workbook.
  • Locate and run a specified macro.
  • Optionally pass comma-separated parameters to the macro.
  • Clean up resources (Excel instance is closed after execution).


Public Method: RunMacroInExcel

NameTypeDescription
FilepathTextFull path to the Excel file (.xlsm) containing the macro.
MacronameTextThe name of the macro to run (as defined in VBA).
ParametersTextOptional. Comma-separated list of parameters to pass to the macro (e.g., "Param1,123,TRUE").


Example Usage:

MssRunMacroInExcel("C:\\Reports\\MyWorkbook.xlsm", "GenerateReport", "2025-06-30,Region1,TRUE");

In VBA:

Sub GenerateReport(ByVal reportDate As String, ByVal region As String, ByVal includeSummary As Boolean)

    ' VBA macro logic here

End Sub


Prerequisites

  • Microsoft Excel must be installed on the server/machine where the extension runs.
  • Excel file must be macro-enabled (.xlsm) and accessible from the specified path.
  • Macros should not require user interaction (avoid MsgBox or InputBox).
  • Your OutSystems environment must allow server-side extensions (Integration Studio).


 Limitations

  • Not compatible with environments where Excel cannot run (e.g., some cloud-hosted setups).
  • Runs Excel in background: if Excel crashes or hangs, the process may linger unless properly cleaned up.
  • Parameters are always passed as strings. You may need to convert them in the VBA macro.


Resource Management

  • The component closes the workbook and quits Excel after execution.
  • It uses Marshal.ReleaseComObject and GC.Collect() to force cleanup of COM objects and memory