“Sharing Violation”: Why Excel won’t let you save over an existing file.

The warning "Your changes could not be saved to 'filename.xlsx' because of a sharing violation. Try saving to a different file." halts your save operation when you try to update an existing document. This error does not mean another colleague is actively typing inside your spreadsheet. Instead, it indicates that an external Windows process—such as a file previewer, an antivirus engine, or an automated backup agent—has seized an exclusive file lock on your workbook at the exact millisecond Excel tried to overwrite it.

Quick Answer

Press F12 immediately and save your workbook with a new name (such as Budget_v2.xlsx) on your Desktop to secure your data. To eliminate the error on the original file, open Windows File Explorer, press Alt + P to turn off the Preview Pane, and close any background indexing or cloud-sync tools locking the folder.


The Mechanism Behind the Error

To understand why a sharing violation occurs, you must look at how Excel saves files. To guard against file damage during power outages, Excel uses a three-stage atomic save process:

  1. Excel writes your updated data to a temporary file (e.g., A7B1C2D3.tmp).
  2. Excel deletes the original workbook (Budget.xlsx).
  3. Excel renames A7B1C2D3.tmp to Budget.xlsx.

A sharing violation (Windows Error Code 32: ERROR_SHARING_VIOLATION) happens when another program opens Budget.xlsx or the .tmp file in read-only or exclusive mode between Step 1 and Step 3. Because the external program holds an open handle, Windows denies Excel permission to delete or rename the file, causing the save routine to fail.


Step 1: Secure Your Data Immediately

Do not repeatedly click “Retry” or force-close the application. If you close Excel before completing a secondary save, your current modifications are deleted.

  1. Press F12 on your keyboard (or go to File > Save As).
  2. Choose a local folder outside the affected directory, such as C:\Temp or your Desktop.
  3. Add a timestamp or version marker to the filename (e.g., Model_Recovered.xlsx).
  4. Click Save.

Once your changes are stored, use the steps below to find and stop the process that caused the lock.


Diagnostic Step 2: Disable the Windows Explorer Preview Pane

The single most common cause of Excel sharing violations is the Windows File Explorer Preview Pane.

When the Preview Pane is active, clicking a file in Explorer launches prevhost.exe (the Windows Preview Handler). This process reads the file so it can render a visual thumbnail in the side pane. If you attempt to save the workbook in Excel while Windows Explorer is previewing it, prevhost.exe locks the file handle, blocking Step 2 of Excel’s save cycle.

[Windows File Explorer]  ──► prevhost.exe locks Budget.xlsx (Reading Preview)
                                     ▲
                                     │  [CONFLICT: Sharing Violation]
                                     ▼
[Microsoft Excel]        ──► Attempts to delete/rename Budget.xlsx during save

The Fix:

  1. Open File Explorer (Windows Key + E).
  2. Press Alt + P to close the Preview Pane (or click View > Show > Preview pane to uncheck it).
  3. Switch off the Details pane as well (View > Show > Details pane).
  4. Return to your original workbook in Excel and re-attempt the save.

Diagnostic Step 3: Identify the Locking Process with Resource Monitor

If the Preview Pane is not the culprit, a background application is holding the file handle. You can track down the exact executable using Windows Resource Monitor.

  1. Press Ctrl + Shift + Esc to open Task Manager.
  2. Go to the Performance tab and click Open Resource Monitor at the bottom.
  3. In Resource Monitor, click the CPU tab.
  4. Expand the Associated Handles section.
  5. In the Search Handles box, type the exact name of your locked workbook (e.g., Budget.xlsx).
  6. Review the list:
Image Column (Process)What It MeansAction Required
explorer.exeWindows Explorer has frozen the file handleRestart Windows Explorer via Task Manager
prevhost.exePreview handler activeTerminate prevhost.exe in Details tab
OneDrive.exe / Dropbox.exeCloud engine syncing during savePause syncing for 10 minutes
Antivirus (MsMpEng.exe, etc.)Real-time scanner checking the fileAdd file extension exclusion

To terminate the locking process, right-click the offending program in Resource Monitor and select End Process.


Diagnostic Step 4: Address Ghost Owner Files

If a prior Excel session crashed or lost its connection to a network share, an invisible owner file (~$filename.xlsx) might still linger in the folder. While owner files typically cause “File is locked for editing” warnings, an orphaned owner file can also trick Excel’s rename engine into throwing a sharing violation.

To verify and clear these leftover files, follow the cleanup steps in “The file is locked for editing”: How to kill “Ghost” owner files (~$filename).


Diagnostic Step 5: Configure Antivirus Exclusions

If sharing violations occur unpredictably across different folders, your endpoint security scanner is likely intercepting Excel’s temporary files.

When Excel generates its intermediate .tmp file, aggressive antivirus software immediately grabs that file to run a heuristic virus scan. If the scan takes longer than a few milliseconds, Excel’s request to rename the .tmp file is blocked by Windows.

  1. Open your corporate or local antivirus dashboard.
  2. Locate the Exclusions or Whitelisting settings.
  3. Add a process exclusion for EXCEL.EXE.
  4. Add a file extension exclusion for temporary Office documents: .tmp and ~$*.xlsx.

If your workbook fails to save even after saving to a different directory name, permissions on the disk itself may be restricted; refer to “Document not saved”: Troubleshooting permission and disk space issues.