Fix Power Automate Excel Office Script Errors After Editing
Question details
The user needs to resolve Power Automate errors that occur when an Excel workbook or Office Script is edited, replaced, or recreated.

- Product
- Microsoft Excel Office Scripts with Power Automate
- Device & OS
- not provided
- Scenario
- A Power Automate flow runs an Excel Office Script against a workbook that may have been edited or replaced with another file using the same name.
- Observed behavior
- The flow fails because Power Automate may still reference the original workbook file ID, an unavailable script, the wrong environment, or a connection without sufficient access.
Confirm the current workbook exists in the expected OneDrive or SharePoint location and note whether it was replaced or recreated. Open the Office Script editor to verify that the script is saved and available in the same environment used by the flow.
Retrieve the current workbook file properties before running the script
Use this solution when the workbook was replaced, recreated, or moved and the flow may still hold an outdated file ID.
Power Automate identifies the workbook by its file ID rather than only by its filename. A newly created workbook with the same name receives a different ID, so the flow must retrieve the current file dynamically before the script runs.
In Power Automate, open My flows, select the affected flow, and choose Edit.
Select New step, search for the OneDrive for Business or SharePoint file action that retrieves file properties, and configure it to use the created or modified workbook.
In the Excel Online (Business) Run script action, open the File or Workbook field and select the identifier returned by the file properties action instead of a previously selected static file.
Select Save, then choose Test and run the flow with the current workbook to confirm that the script targets the newly retrieved file.
Reconfigure the Run script action and verify access
Use this solution when the workbook was not replaced but the script, environment, or flow connection changed after editing.
Use WPS Office as a Lightweight Alternative for Excel Workbook Editing
WPS Office provides a familiar spreadsheet experience for opening, editing, and saving Excel workbooks when you need a free, lightweight alternative to Microsoft Office. It supports common Excel formats and makes migration straightforward, although Power Automate and Microsoft Office Scripts remain Microsoft services that must be configured separately.
- 1. Install WPS Office: Download and install WPS Office, then open WPS Spreadsheets from the application launcher.
- 2. Open the Excel workbook: Select Open, browse to the workbook, and load the XLS or XLSX file you need to review or edit.
- 3. Save in an Excel-compatible format: After editing, choose Menu > Save As and select Excel 2007-365 Workbook (*.xlsx) when the file must remain compatible with Microsoft Excel.

Frequently Asked Questions
Why does Power Automate fail when the replacement workbook has the same name?
Power Automate uses the workbook's file ID, not just its filename. A replacement or newly recreated workbook receives a new ID, so retrieve the current file properties and pass the returned identifier to the Run script action.
How can I make a flow use the current workbook dynamically?
Edit the flow and add a OneDrive for Business or SharePoint action that retrieves the properties of the created or modified file. In Excel Online (Business) > Run script, select the file identifier from that action instead of a static workbook selection.
What should I check if the Office Script is missing from Power Automate?
Open the workbook in Excel, go to Automate, confirm the script is saved, and make sure it is available in the environment connected to Power Automate. Then refresh the flow and reselect the script in the Run script action.
Can an expired connection cause an Excel Office Script flow to fail?
Yes. In Power Automate, open Data > Connections and repair or reauthenticate the Excel Online (Business), OneDrive, or SharePoint connection. The connection account must also have permission to access the workbook and script.




