"File is locked for editing by another user" — including when that user is you
A document opens read-only and names someone who is not in it — sometimes the person trying to open it. A stale owner file, an open handle on the file server, or a SharePoint checkout is holding the lock after the session that created it has gone.
What you see
"File in use — document is locked for editing by another user" naming a colleague who has it closed, or naming the current user, or showing "another user". Read-only opens fine; taking the lock never becomes available.
What is actually wrong
Office creates a hidden owner file named ~$ plus the document name and deletes it on a clean close. A crash, a dropped VPN or a killed process leaves it behind and the lock outlives the session. On a file server the SMB handle can outlive the client for the same reason. In SharePoint and OneDrive the equivalent is a checkout, or a lock the service holds for up to ten minutes after a client disappears.
Codes and articles
Start here — find out which fix applies
A script that runs the 2 inspection commands from the write-up below and prints what each one returned. It reads the machine and changes nothing — every command that could write, delete, start or stop is excluded from it by construction. Run this first, then pick the fix its output points at.
Fixes (3)
Remove the stale owner file
Always check this first, wherever the file lives. It costs a minute and it is the answer most of the time.
Confirm nobody genuinely has the document open. Ask, do not assume — deleting the owner file while someone is editing invites two people saving over each other.
Find the owner file. It is hidden, so it will not show in Explorer with default settings.
Get-ChildItem '\\fileserver\share\folder' -Filter '~$*' -Force | Select-Object Name, LastWriteTime, LengthThe LastWriteTime tells you when the session that left it behind started. One from three weeks ago is certainly stale; one from four minutes ago probably means someone really is in the file.
Delete the owner file for the document in question. The name is ~$ followed by the document name, sometimes with the first characters truncated.
Remove-Item '\\fileserver\share\folder\~$Budget.xlsx' -ForceReopen the document. It should now open for editing.
Close the stale handle on the file server
The owner file is gone or absent and the lock persists, and the file is on a Windows file server. Closing a handle that is genuinely in use discards any unsaved work in that session without warning the person doing the work, so confirm the session is stale before you close anything.
Find the open handle by file name.
Get-SmbOpenFile | Where-Object Path -like '*Budget.xlsx*' | Select-Object FileId, SessionId, ClientUserName, ClientComputerName, PathCheck whether that session is actually alive before closing anything.
Get-SmbSession -SessionId <SessionId> | Select-Object ClientComputerName, ClientUserName, NumOpens, SecondsIdleA high SecondsIdle on a session whose owner says they are not in the file is the confirmation you want. Closing a live handle discards whatever that client has not yet written.
Close the handle.
Close-SmbOpenFile -FileId <FileId> -ForceHave the user reopen the document.
If this happens repeatedly on the same share, look at the underlying cause rather than closing handles forever — an unstable VPN, roaming laptops sleeping with files open, or oplocks misbehaving with a third-party filter driver are the usual three.
Get-SmbOpenFile | Where-Object Path -like '*Budget.xlsx*'Release a SharePoint or OneDrive lock
The file is in SharePoint, Teams or OneDrive.
Open the library in the browser and check whether the file shows as checked out. A checked-out file shows a small green arrow, and its Checked Out To column names the holder.
If it is checked out, discard the checkout from the library — the ⋯ menu → More → Discard check out. A site administrator can do this for anyone else's checkout.
If it is not checked out, wait ten minutes. A short-term lock is taken when a client opens the file and is released automatically when the client disappears; there is no way to clear it early and no reason to.
This is the step people skip, and it is why the same file is reported three times in twenty minutes. The lock expires on its own.
Have the user close Office completely and let the sync client settle, since a local Office process holding the file will keep re-taking the lock.
Get-Process WINWORD,EXCEL,POWERPNT -ErrorAction SilentlyContinue | Stop-Process -ForceIf the document keeps locking for one user only, check they are opening it from the sync client or the browser and not through a mapped drive to the SharePoint URL, which does not participate in co-authoring properly.
Related faults
Where this stops. This write-up was written and checked by hand. It says what each step changes, how to confirm it worked and how to reverse it, and anything destructive is flagged before you reach it. If it does not match what your machine is doing, search the Support Centre for the exact code or message — and when something needs a person, get in touch.