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, pressAlt + Pto 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:
- Excel writes your updated data to a temporary file (e.g.,
A7B1C2D3.tmp). - Excel deletes the original workbook (
Budget.xlsx). - Excel renames
A7B1C2D3.tmptoBudget.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.
- Press F12 on your keyboard (or go to File > Save As).
- Choose a local folder outside the affected directory, such as
C:\Tempor your Desktop. - Add a timestamp or version marker to the filename (e.g.,
Model_Recovered.xlsx). - 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:
- Open File Explorer (
Windows Key + E). - Press Alt + P to close the Preview Pane (or click View > Show > Preview pane to uncheck it).
- Switch off the Details pane as well (View > Show > Details pane).
- 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.
- Press Ctrl + Shift + Esc to open Task Manager.
- Go to the Performance tab and click Open Resource Monitor at the bottom.
- In Resource Monitor, click the CPU tab.
- Expand the Associated Handles section.
- In the Search Handles box, type the exact name of your locked workbook (e.g.,
Budget.xlsx). - Review the list:
| Image Column (Process) | What It Means | Action Required |
|---|---|---|
explorer.exe | Windows Explorer has frozen the file handle | Restart Windows Explorer via Task Manager |
prevhost.exe | Preview handler active | Terminate prevhost.exe in Details tab |
OneDrive.exe / Dropbox.exe | Cloud engine syncing during save | Pause syncing for 10 minutes |
Antivirus (MsMpEng.exe, etc.) | Real-time scanner checking the file | Add 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.
- Open your corporate or local antivirus dashboard.
- Locate the Exclusions or Whitelisting settings.
- Add a process exclusion for
EXCEL.EXE. - Add a file extension exclusion for temporary Office documents:
.tmpand~$*.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.