How to Fix 'The Script Ran with Errors' in Excel Office Scripts
Question details
The user needs to resolve an issue where Excel Office Scripts fail to execute, showing error messages or unexpected task pane failures.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Running automated Office Scripts in Excel desktop or web environments.
- Observed behavior
- The script execution fails, displaying an error message like 'The Script Ran with Errors' or 'An unexpected error occurred. Close the task pane to try again.'
Check your script code for any obvious syntax errors and ensure you have a stable internet connection, as Office Scripts rely on cloud services to run.
Clear Office Cache and Restart Excel
Clearing the temporary web extension cache can resolve unexpected task pane errors preventing scripts from running.
Office Scripts use a web-based task pane interface. Corrupted cache files in this environment often lead to unexpected runtime errors.
Close the Office Scripts task pane and exit the Excel application completely.
Press the Windows Key + R on your keyboard to open the Run dialog box.
Type %LOCALAPPDATA%\Microsoft\Office\16.0\Wef\ into the box and press Enter.
Select and delete all the files and folders within this directory, then reopen Excel and test your script.

Disable Conflicting COM Add-ins
Third-party add-ins might interfere with the execution of Office Scripts.
Run an Online Repair for Office
If core Excel components or dependencies are corrupted, an Online Repair can restore script functionality.
Try WPS Office for Reliable Macro and Script Execution
If you frequently encounter errors with cloud-based Microsoft Office Scripts, consider switching to WPS Office. It provides a lightweight, highly compatible environment with robust support for both VBA and modern JavaScript Macros—completely free.
- 1. Download WPS Office: Download and install the free WPS Office suite from the official website.
- 2. Open Your Spreadsheets: Open your existing .xlsx or .xlsm files directly in WPS Spreadsheet.
- 3. Use JS Macros or VBA: Navigate to the Tools tab to access reliable, offline JS Macros and VBA for your automation needs.

Frequently Asked Questions
Why do Office Scripts run differently in Excel web and desktop?
Office Scripts may behave differently because the browser and desktop environments handle dependencies, compile times, and caching in unique ways. A script that fails on the desktop might run smoothly in the browser, and vice versa.
What is the Wef folder in Microsoft Office?
The Wef (Web Extension Framework) folder located at %LOCALAPPDATA%\Microsoft\Office\16.0\Wef\ stores temporary cache files for Office web add-ins and cloud-based features like Office Scripts. Clearing it often fixes task pane load errors.
Can I check specific logs for Office Script errors?
Yes. If your scripts are integrated with Power Automate (Standard workflows in Azure Logic Apps), you can check the workflow run logs to find specific compilation or runtime errors affecting your scripts.
Are COM add-ins known to conflict with Office Scripts?
Yes, certain legacy COM add-ins can conflict with modern web-based task panes in Excel, preventing Office Scripts from rendering or executing properly.




