OneDrive File Issues

Why Excel AutoSave Bypasses Workbook_BeforeSave VBA Code

Anum MushtaqAnum Mushtaq Nov 10, 2026 870 views

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.

Why Excel AutoSave Bypasses Workbook_BeforeSave VBA Code
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 you start

Before implementing any workarounds, ensure you have administrative access to your OneDrive or SharePoint folders so you can modify file permission policies effectively.

Solution 1Recommended

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.

1
Access cloud storage settings

Navigate to the target file or folder in your SharePoint or OneDrive web interface.

2
Modify access rights

Click on 'Manage Access' and change the user permissions from 'Can edit' to 'Can view'.

3
Enforce read-only access

Distribute the file as a read-only document so users are forced to save a local copy if they wish to make changes.

Apply SharePoint or OneDrive Permission Policies
Security Note: Permission policies provide robust server-side security, which cannot be bypassed by a user turning off macros or utilizing AutoSave.
Free Microsoft Office alternative

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. 1. Download the installer: Visit the official WPS Office website and download the free installation package.
  2. 2. Install WPS Office: Run the downloaded file and follow the on-screen prompts to complete the quick installation.
  3. 3. Open your spreadsheets: Launch WPS Spreadsheets and open your existing .xlsx or .xlsm files to start editing immediately.
Fully compatible with Microsoft Excel file formats (.xlsx, .xls, .xlsm).Familiar user interface requiring zero learning curve for Excel users.Lightweight installation with fast loading times and smooth performance.Flexible cloud storage options giving you manual control over file synchronization.
microsoft office alternative - wps office

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.