Why Excel AutoSave Bypasses Workbook_BeforeSave VBA Code
Question details
The user needs to understand why their Workbook_BeforeSave VBA code fails to prevent AutoSave when Excel files are stored on OneDrive or SharePoint.

- Product
- Microsoft Excel, OneDrive, SharePoint
- Device & OS
- not provided
- Scenario
- Attempting to prevent users from saving sensitive data or unwanted changes using the Workbook_BeforeSave event in VBA.
- Observed behavior
- The Workbook_BeforeSave cancellation is bypassed by Excel's AutoSave feature when the file is synced with cloud storage.
Before implementing any workarounds, ensure you have administrative access to your OneDrive or SharePoint folders so you can modify file permission policies effectively.
Apply SharePoint or OneDrive Permission Policies
The most reliable way to prevent unwanted saves is to restrict write access at the folder or file level, rather than relying on VBA macros.
Because AutoSave is managed by Excel's deep integration with OneDrive and SharePoint, local VBA events like Workbook_BeforeSave cannot reliably intercept background sync processes. Relying on VBA for security is generally discouraged when dealing with modern cloud environments.
Navigate to the target file or folder in your SharePoint or OneDrive web interface.
Click on 'Manage Access' and change the user permissions from 'Can edit' to 'Can view'.
Distribute the file as a read-only document so users are forced to save a local copy if they wish to make changes.

Disable AutoSave upon Workbook Open via VBA
You can programmatically attempt to turn off AutoSave when the workbook opens, though it is not foolproof as users can manually re-enable it.
Experience a Seamless and Free Office Suite with WPS Office
If you are experiencing macro and cloud-sync conflicts in Microsoft Excel, consider WPS Office as your go-to productivity suite. WPS Office is a lightweight, highly compatible alternative that seamlessly handles Excel files with a familiar interface, giving you full control over your local and cloud saves.
- 1. Download the installer: Visit the official WPS Office website and download the free installation package.
- 2. Install WPS Office: Run the downloaded file and follow the on-screen prompts to complete the quick installation.
- 3. Open your spreadsheets: Launch WPS Spreadsheets and open your existing .xlsx or .xlsm files to start editing immediately.

Frequently Asked Questions
Why does Workbook_BeforeSave work on local files but not on OneDrive?
When a file is saved locally, Excel handles the save event directly, allowing VBA to intercept it. On OneDrive or SharePoint, AutoSave continuously syncs changes in the background, which inherently bypasses the standard BeforeSave event trigger.
Can I use 'Saved = True' to trick Excel into not saving to the cloud?
No. Setting 'ThisWorkbook.Saved = True' or canceling the 'BeforeClose' event does not guarantee that background cloud syncs haven't already captured and uploaded the recent changes.
Is there a way to permanently disable AutoSave for a specific workbook?
You can configure Excel to disable AutoSave by default, or use a VBA script on workbook open, but users can still manually toggle it back on in the top-left corner of the Excel ribbon. Using read-only permissions on SharePoint is the only permanent solution to prevent unwanted changes.




