Fix Office Scripts Running Slowly from Excel Buttons
Question details
The user needs to resolve an issue where Office Scripts freeze or take a long time to execute when triggered via worksheet buttons in Excel.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Triggering Office Scripts repeatedly using in-sheet buttons during regular spreadsheet workflows.
- Observed behavior
- Scripts run normally when executed manually but become extremely slow or get stuck on 'Preparing to run button' when repeatedly started from Excel buttons.
Ensure your Excel application and web browser are fully updated to the latest versions, and verify that your internet connection is stable if using Excel for the Web.
Optimize Script Performance and Refresh the Browser Session
Minimizing unnecessary API calls and clearing long-running browser sessions can prevent scripts from hanging.
Office Scripts performance is heavily dependent on the Excel web client. Repeatedly running scripts from buttons can accumulate memory and cache in the browser session, causing lag.
Check your Office Script code to minimize Excel API calls and remove unnecessary console logging.
Close your current browser tab or Excel application to clear active memory.
Reopen the browser or Excel, navigate back to your workbook, and test the button again to see if the session reset resolved the lag.

Disable Add-ins and Check for Software Conflicts
Third-party add-ins or background programs might interfere with Excel's ability to execute button-triggered scripts efficiently.
Perform an Online Repair of Microsoft Office
If the issue persists on the desktop client, repairing the Office installation can fix corrupted files causing script execution failures.
Experience Smooth Spreadsheet Automation with WPS Office
If Microsoft Excel continues to freeze when running automated scripts, consider switching to WPS Office. It provides a lightweight, highly compatible alternative with robust JS Macro support for smooth automation without the heavy resource drain.
- 1. Download WPS Office: Download and install WPS Office for free from the official website.
- 2. Open Your Workbook: Launch WPS Spreadsheets and open your existing Excel workbook.
- 3. Run Macros Seamlessly: Utilize the lightweight WPS environment to run macros and automation scripts without performance lag.

Frequently Asked Questions
Why do my Office Scripts run fine manually but lag when using a button?
Running scripts from a button can sometimes trigger different event handlers or accumulate web client session data differently than a manual run, leading to memory bloat or interface lag over multiple rapid executions.
Does clearing my browser cache help with Excel web script performance?
Yes, if you are using Excel on the Web, clearing your browser's cache and cookies can resolve session-related hangs and improve the overall execution speed of your Office Scripts.
Can third-party add-ins affect Office Script execution?
Absolutely. Active X or COM add-ins can conflict with the underlying processes Excel uses to trigger scripts from sheet buttons, causing them to freeze or stall indefinitely on the 'Preparing to run button' screen.




