Trigger Excel VBA Macros or Office Scripts from Power Automate
Question details
The user needs a reliable way to trigger Excel automation from Power Automate, using either Office Scripts or existing VBA macros.

- Product
- Microsoft Excel, Power Automate, and Office Scripts
- Device & OS
- not provided
- Scenario
- A scheduled or flow-based process must run actions for one or more Excel workbooks without relying on Workbook Open events in an XLAM add-in.
- Observed behavior
- An XLAM add-in does not automatically run Workbook Open events for every workbook, and Task Scheduler cannot directly trigger VBA events in arbitrary open workbooks.
Identify whether the automation can be rewritten as an Office Script or must remain as VBA. For VBA desktop automation, confirm that the target workbooks are trusted, macros are permitted, and the desktop machine is available when the flow runs.
Use an Office Script in a Power Automate cloud flow
Use this recommended approach when the workbook is stored in OneDrive or SharePoint and the VBA process can be converted to Office Scripts.
Office Scripts are designed to run with Power Automate. A cloud flow can trigger a script on a selected workbook without depending on Excel Workbook Open events or an add-in being loaded.
Open the workbook in Excel for the web, select the Automate tab, and choose New Script. Recreate the required workbook actions, then save the script with a clear name.
In Power Automate, select Create and choose a trigger such as Recurrence, When a file is created or modified, or an instant cloud flow trigger.
Select New step, search for Excel Online (Business), and choose Run script. Select the OneDrive for Business or SharePoint location, document library, target workbook, and saved Office Script.
Save and test the flow with a copy of the target workbook. Review the flow run history to confirm that the script completed and that the expected workbook changes were saved.

Run an existing VBA procedure with Power Automate Desktop
Use this option when the VBA code cannot be converted and a controlled Windows machine can open, process, save, and close each workbook.
Use WPS Office for lightweight Excel workbook and macro editing
Power Automate and Office Scripts are Microsoft services, so WPS Office cannot run or repair those cloud-flow integrations. For everyday spreadsheet work, WPS Office is a free, lightweight alternative with a familiar interface and straightforward migration for compatible Excel files.

Frequently Asked Questions
Can a Power Automate cloud flow run Excel VBA macros?
No. Power Automate cloud flows use the Excel Online (Business) connector and can run Office Scripts, not desktop VBA macros. To run VBA, use Power Automate Desktop on a configured Windows machine.
Why does my XLAM add-in not run Workbook Open code for every workbook?
An add-in does not automatically receive the Workbook Open event for all workbooks. Workbook event code must be placed in the relevant workbook or handled through a deliberately configured application-level event design.
Where must a workbook be stored to run an Office Script from Power Automate?
For the Excel Online (Business) Run script action, store the workbook in OneDrive for Business or SharePoint and select that location, library, file, and script in the action settings.
Can Task Scheduler trigger a VBA macro in a workbook that is already open?
Task Scheduler cannot directly invoke VBA events in an arbitrary existing Excel session. A more controlled approach is to schedule a desktop flow that opens the workbook, runs a named macro, saves it, and closes Excel.
What macro should Power Automate Desktop run?
Use a public VBA procedure with a stable, explicit name, such as Public Sub UpdateMonthlyReport(). In Power Automate Desktop, enter that procedure name in the Run Excel macro action.




