When you try to open a Microsoft Office file stored on a SharePoint document library or a network drive, you may see the error message: “The file is locked for shared use by
Key Takeaways: Working Around the File Lock Error
- SharePoint library > Open in App: Forces Office to open the file directly from the server, bypassing stale lock files.
- Windows File Explorer > Show hidden items: Reveals the hidden lock file (.~lock. or ~$ prefix) that you can delete.
- PowerShell Remove-Item cmdlet: Deletes lock files on SharePoint mapped drives or network shares in bulk.
Why Office Creates a Lock File During Shared Editing
When you open an Office file from a SharePoint document library or a network share, Office creates a temporary lock file on the server or in the same folder. This lock file has a name that starts with ~$ or .~lock. followed by the original file name. The lock file contains metadata about the user who opened the file, including their username and the time the file was opened. Its purpose is to prevent two users from overwriting each other’s changes simultaneously.
The error “The file is locked for shared use” appears when Office detects an existing lock file that matches the current file. The lock file is supposed to be deleted automatically when the user closes the file normally. However, the lock file can remain in place if the user’s Office application crashes, the network connection drops, or the user closes the laptop without saving. The system then sees the stale lock file and blocks any new editing session.
Where the Lock File Lives
For files stored on a SharePoint document library accessed via a mapped drive or the OneDrive sync client, the lock file is stored in the same folder as the original file. For files opened directly in the browser through SharePoint, the lock file is held on the SharePoint server and is not visible to users. In the browser case, the lock is released after a timeout period of about 15 to 30 minutes.
When the Lock File Does Not Release
The lock file persists in these common scenarios:
- The user who holds the lock closes the file without saving, and Office does not delete the lock file.
- The user’s computer goes to sleep or hibernates while the file is still open.
- The network connection to the SharePoint server is interrupted during a save operation.
- The user opens the file from a mapped drive instead of using the SharePoint web interface.
Workarounds to Remove the File Lock
Before trying any workaround, confirm that the user listed in the error message is not actively editing the file. If they are, ask them to close the file. If they are not, use one of the following methods to clear the lock.
Method 1: Open the File from SharePoint in Browser
Opening the file directly in the browser bypasses any local lock file and forces SharePoint to check the server-side lock status. This method works when the lock file is on a mapped drive or sync folder.
- Navigate to the SharePoint document library
Open your web browser and go to the SharePoint site that contains the file. Click Documents in the left navigation to open the library. - Open the file with the browser app
Click the file name to open it in the browser version of Word, Excel, or PowerPoint. If prompted, select Edit in Browser instead of Edit in Desktop App. - Save a copy to clear the lock
Once the file opens, go to File > Save As > Download a Copy. Save the copy to your local drive. Then upload the copy back to the library, overwriting the original. This action deletes the stale lock file on the server.
Method 2: Delete the Hidden Lock File in Windows File Explorer
If the file is stored on a mapped network drive or a SharePoint folder synced with OneDrive, you can delete the lock file directly.
- Enable hidden files in File Explorer
Open File Explorer. Click the View tab on the ribbon. Check the box labeled Hidden items. - Locate the lock file
Browse to the folder containing the locked file. Look for a file that starts with~$followed by the original file name. For example, if the original file isReport.docx, the lock file is~$Report.docx. Alternatively, look for a file named.~lock.Report.docx#. - Delete the lock file
Right-click the lock file and select Delete. Confirm the deletion. The original file is now unlocked. Open it normally.
Method 3: Use PowerShell to Remove Lock Files
If multiple files in a folder are locked, use PowerShell to delete all lock files at once. This method is also useful for network administrators managing shared drives.
- Open PowerShell as administrator
Press the Windows key, type PowerShell, right-click Windows PowerShell, and select Run as administrator. - Run the Remove-Item command
Type the following command and press Enter:Remove-Item -Path "C:\Users\YourName\SharePoint\Shared Documents\~$" -Force
Replace the path with the actual path to your SharePoint sync folder or network drive. The-Forceparameter deletes hidden and read-only files. - Verify the lock is removed
Navigate to the folder in File Explorer and confirm that the~$files are gone. Open the original file to verify it is no longer locked.
Method 4: Wait for the Server-Side Lock Timeout
If you opened the file through the SharePoint web interface and cannot delete the lock file because it is on the server, the lock automatically expires after 15 to 30 minutes. This timeout is controlled by the Office Web Apps server. During this period, no user can edit the file. To check if the lock has expired, refresh the SharePoint library page after 30 minutes and try to open the file.
If the File Lock Error Persists After These Workarounds
“The file is locked for shared use” error appears on a file opened from a SharePoint site that uses co-authoring
Co-authoring in SharePoint requires Office to communicate with the server to track changes. If the lock persists, the user listed in the error may have the file open in a desktop app that is not responding. Ask the user to force-close all Office applications. On the user’s machine, open Task Manager with Ctrl+Shift+Escape, select any Word, Excel, or PowerPoint process, and click End Task. This action releases the lock on the server.
“The file is locked for shared use” error appears after a network interruption
A dropped network connection can leave a lock file on the SharePoint server. In this case, the lock file is not visible to users. The only workaround is to wait for the server-side timeout. To prevent this in the future, always save files before closing the laptop lid or switching networks.
“The file is locked for shared use” error appears on a file stored in a SharePoint folder synced with OneDrive
OneDrive sync can sometimes create a local lock file that conflicts with the server lock. Pause and resume OneDrive sync to clear the local lock. Right-click the OneDrive icon in the system tray, select Pause syncing, choose 2 hours, then after one minute click the OneDrive icon again and select Resume syncing. Try opening the file again.
| Item | Browser-Based Opening | Desktop App Opening | Mapped Drive Opening |
|---|---|---|---|
| Lock file location | SharePoint server only | Local sync folder or server | Network share folder |
| Lock file visible to users | No | Yes, if hidden files are shown | Yes, if hidden files are shown |
| Lock release method | Server timeout (15-30 min) | Delete ~$ file or wait | Delete ~$ file |
| Best workaround | Wait or download a copy | Show hidden items and delete lock | PowerShell Remove-Item |
You can now resolve the “The file is locked for shared use” error by identifying the lock file location and using the appropriate workaround. For files opened through the browser, waiting for the server timeout is the only option, but you can avoid the error by always opening files from the SharePoint web interface instead of a mapped drive. A useful advanced tip is to configure Office to automatically save recovery information every minute, which reduces the chance of a crash leaving a stale lock file. To do this, go to File > Options > Save and set Save AutoRecover information every 1 minute.