You open an Excel file stored in OneDrive for Business and see the message “File is locked for editing by [Your Name]” even though you closed Excel hours ago. This happens when the Office document cache or the OneDrive sync engine retains a stale lock on the file. The lock prevents any user — including you — from editing the file until the session is released. This article explains why the lock persists and provides five tested methods to remove it.
Key Takeaways: How to Unlock an Excel File Stuck in a Closed Session
- Excel > File > Options > Save > Cached files: Clearing the Office Document Cache removes stale session locks that persist after Excel closes.
- OneDrive Settings > Account > Unlink this PC: Unlinking and relinking OneDrive resets the sync relationship and releases file locks held by the sync engine.
- Windows Task Manager > Details tab > Excel.exe: Force-ending orphaned Excel background processes eliminates locks that the normal close command missed.
Why Excel Files Stay Locked After the Session Ends
When you open an Excel file from OneDrive for Business, Office 365 creates a temporary lock file — a hidden file with a name that starts with ~$ — in the same folder as the original file. This lock file signals to other users that the file is in use. When you close Excel normally, the application deletes the lock file and releases the session. But in three situations the lock persists:
Orphaned Excel Processes
If Excel crashes, if Windows shuts down unexpectedly, or if a laptop battery dies while the file is open, the Excel.exe process may remain running in the background. The lock file is not deleted because the normal close routine never executed. The OneDrive sync engine sees the lock file and continues to report the file as locked by the original session.
Office Document Cache
Office 365 stores a local copy of every file you open in the Office Document Cache. This cache can hold a stale lock reference even after the original file is closed. When OneDrive syncs the folder, it checks the cache and sees an active lock. The sync engine then prevents any edits until the cache is cleared.
OneDrive Sync Engine Lock
OneDrive for Business maintains its own file-lock tracking mechanism. If the sync engine detects that a file was opened by an Office application and the lock was not properly released, it holds the file in a locked state for up to 15 minutes. During that window, all other users see the “Locked for editing” message. In some cases the lock can persist indefinitely if the sync engine encounters a conflict or a stalled upload.
Steps to Release the Stale Lock on an Excel File
Use these methods in the order shown. Start with the simplest and move to the more aggressive reset only if needed.
Method 1: Force-Close Orphaned Excel Processes
- Open Task Manager
Press Ctrl + Shift + Escape. Click More details if you see only the compact view. - Switch to the Details tab
Click the Details tab. Locate every instance ofEXCEL.EXEin the list. If you see more than one, the extra processes are likely orphaned. - End the processes
Right-click eachEXCEL.EXEentry and select End task. Confirm the action if prompted. Repeat this for every instance. - Verify the lock is released
Open the Excel file from OneDrive in your browser at onedrive.com. If the file opens in Excel Online without a lock message, the fix worked.
Method 2: Clear the Office Document Cache
- Open Excel Options
Start Excel. Click File > Options > Save. - Locate the cache button
Scroll to the Cached files section. Click Clear cached files. - Confirm the action
Click Yes in the confirmation dialog. Excel deletes all locally cached Office documents. - Reopen the file
Navigate to the OneDrive folder in File Explorer and open the Excel file. The lock should be gone.
Method 3: Delete the Hidden Lock File
- Show hidden files
In File Explorer, click View > Show > Hidden items. Hidden files become visible. - Navigate to the folder
Go to the OneDrive folder that contains the locked Excel file. - Find the lock file
Look for a file named~$[filename].xlsx— for example,~$Budget.xlsx. This is the lock file. - Delete the lock file
Select the lock file and press the Delete key. Confirm the deletion if prompted. - Refresh and test
Press F5 to refresh the folder. Open the Excel file. The lock message should no longer appear.
Method 4: Unlink and Relink OneDrive
- Open OneDrive Settings
Right-click the OneDrive cloud icon in the system tray. Select Settings. - Go to the Account tab
Click the Account tab. Click Unlink this PC. - Confirm the unlinking
Click Unlink account in the confirmation dialog. OneDrive stops syncing and removes all local file locks. - Sign in again
Open OneDrive from the Start menu. Sign in with your work or school account. Let the sync complete. - Test the file
Open the Excel file. The lock should be released because the sync engine reset its lock state.
Method 5: Reset the OneDrive Sync Engine
- Open a Command Prompt as Administrator
Press the Windows key, type cmd, right-click Command Prompt, and select Run as administrator. - Run the reset command
Type%localappdata%\Microsoft\OneDrive\onedrive.exe /resetand press Enter. The OneDrive icon disappears from the system tray. - Wait for the reset to complete
After 30 seconds, type%localappdata%\Microsoft\OneDrive\onedrive.exeand press Enter. OneDrive restarts and re-syncs all files. - Open the Excel file
Navigate to the file and open it. The reset clears all internal lock states, so the file should be editable.
If the Excel File Is Still Locked After the Main Fix
OneDrive Shows the File as “Checked Out” by Another User
When a file is checked out in the OneDrive library, only the person who checked it out can edit it. If that person closed Excel without checking in the file, the lock persists. Ask the user who checked out the file to visit onedrive.com, locate the file, right-click it, and select Discard check out. If that user is unavailable, a SharePoint site owner can force-discard the check-out from the SharePoint admin center.
The File Is Locked by a Co-Authoring Conflict
If two users open the file at the same time, OneDrive creates a conflict copy. The original file may show a lock that belongs to the conflict resolution process. Open the OneDrive folder in File Explorer, look for a file named [filename] (conflict) [username].xlsx, and delete it. Then close and reopen the original file.
Antivirus Software Is Holding the File
Some antivirus programs lock Office files during real-time scanning. Temporarily disable the antivirus real-time protection for 30 seconds, then try to open the Excel file. If the file opens, add the OneDrive folder to the antivirus exclusion list.
| Item | Method 1: End Excel Processes | Method 3: Delete Lock File |
|---|---|---|
| Description | Force-closes orphaned Excel.exe background processes | Manually removes the hidden ~$ lock file from the OneDrive folder |
| When to use | When Excel crashed or was not closed properly | When the lock file is visible and not deleted automatically |
| Risk level | Low — unsaved changes in other Excel files may be lost | Low — deleting the lock file does not affect the original file |
| Time to complete | 1 minute | 2 minutes |
After you release the lock, enable AutoSave in Excel by clicking the AutoSave toggle in the top-left corner of the window. AutoSave saves changes every few seconds and reduces the chance of a stale lock because the file is continuously synced. Also configure OneDrive to always show hidden files so you can spot lock files quickly in the future.