Fix Excel Workbook_Open Macro Running Repeatedly from OneDrive
Question details
The Workbook_Open macro in an XLSM file executes continuously or repeatedly when editing the file stored in OneDrive.

- Product
- Microsoft Excel, OneDrive
- Device & OS
- not provided
- Scenario
- Editing a macro-enabled Excel workbook (XLSM) stored in a synced OneDrive folder.
- Observed behavior
- The Workbook_Open event triggers repeatedly every few seconds during normal editing, making it seem like the file is constantly reopening or refreshing.
Ensure you have saved a local copy of your XLSM file outside of the OneDrive sync folder to prevent accidental data loss or macro corruption during troubleshooting.
Test the File Locally and Pause OneDrive Sync
Isolating the file from OneDrive synchronization helps determine if sync conflicts or background file-locking mechanisms are triggering the macro.
OneDrive's synchronization process or the AutoSave feature can occasionally lock the file state in the background. This can trick Excel into executing the Workbook_Open event repeatedly as the file state is refreshed.
Click the OneDrive cloud icon in your system tray, click the 'Help & Settings' gear icon, select 'Pause syncing', and choose '2 hours'.
Copy the affected XLSM workbook from your OneDrive folder and paste it into a local, non-synchronized directory like your Desktop or Documents folder.
Open the local copy of the workbook in Excel and edit it normally to see if the Workbook_Open macro continues to trigger repeatedly.

Disable AutoSave for the Specific Workbook
Turning off AutoSave prevents Excel from constantly updating the file to OneDrive, which can falsely trigger the open event in certain software builds.
Update Microsoft Office and OneDrive Client
Bugs causing repetitive macro execution are often resolved in newer, patched builds of Microsoft Office and the OneDrive synchronization client.
Try WPS Office for Seamless Macro Execution
If Microsoft Excel and OneDrive synchronization issues continue to disrupt your VBA workflows, consider switching to WPS Office. It provides a highly stable environment for running complex macros without unexpected reload interruptions.
- 1. Download and Install WPS Office: Get the free WPS Office installer from the official website and complete the setup.
- 2. Open Your XLSM File: Launch WPS Spreadsheets, click 'Open', and select your macro-enabled workbook.
- 3. Enable Macros: Click 'Enable Macros' in the security warning prompt to seamlessly run your VBA code.

Frequently Asked Questions
Why does the Workbook_Open macro trigger randomly during editing?
When an XLSM file is stored in a synced location like OneDrive, background synchronization or the AutoSave feature can temporarily lock and refresh the file state. This process can trick Excel into registering a new file open action, thereby triggering the Workbook_Open event repeatedly.
Can multiple users editing the file trigger the Workbook_Open macro?
Yes. If the workbook is shared and multiple users are editing it simultaneously via OneDrive or SharePoint, synchronization updates pushed to your device might cause the workbook to refresh and re-run the open event.
How can I prevent AutoSave from interfering with my Excel macros?
You can disable AutoSave specifically for macro-heavy workbooks by toggling off the AutoSave switch in the top-left corner of the Excel window. Alternatively, you can move the file to a local, un-synced directory while running complex VBA scripts.
Does my version of OneDrive affect Excel macro execution?
Yes, certain builds of the OneDrive sync client or Microsoft Excel can have synchronization conflicts that cause unexpected behaviors, including repeating macros. Updating both applications to their latest builds often resolves these bugs.




