How to Fix ‘File is Locked for Editing by Another User’ in SharePoint & Teams

How to Fix ‘File is Locked for Editing by Another User’ in SharePoint & Teams

Nothing halts productivity faster than opening a critical document in SharePoint or Teams only to see the message: “File is locked for editing by another user”—especially when your colleague claims they closed the file hours ago!

File locking issues in SharePoint Online and Microsoft Teams are a common frustration in modern co-authoring environments. In this post, we will break down why file locks occur, how to clear them quickly without IT intervention, and how to prevent them in your daily workflows.


🛠️ Quick Troubleshooting Flow for Locked Files

1️⃣

Open in Browser

Force SharePoint Online to bypass desktop Office app file locks.

2️⃣

Wait 10 Minutes

SharePoint auto-releases orphaned desktop session locks after 10 min.

3️⃣

Discard Check-In

Site Owners can discard manual check-outs directly from file details.

Why Does SharePoint Lock Files?

SharePoint Online supports real-time co-authoring for Word, Excel, and PowerPoint. However, temporary file locks are triggered under specific technical circumstances:

  • Orphaned Desktop Sessions: If an user edits a document using Excel Desktop and their app crashes or loses internet, Microsoft 365 holds a 10-minute lease lock on the file.
  • Explicit Check-Out: A user checked out the file for exclusive editing but forgot to click Check In when done.
  • Unsupported File Features: Opening legacy Excel files containing macros (`.xlsm`), external data links, or password protection disables real-time co-authoring and forces single-user locking.

Step-by-Step Solutions to Clear Locked Files

Solution 1: Open the Document in Office Web Apps

If Excel or Word desktop says the file is locked, try opening the file in Excel for the Web (via your browser). Office Web Apps often bypass desktop client lock leases, allowing you to edit or make a copy immediately.

Solution 2: Discard Check-Out (For Site Owners & Admins)

If a colleague manually checked out the file, a small red lock icon will appear on the file thumbnail in SharePoint. Site Owners can unlock it directly:

  1. Hover over the locked file in SharePoint and click the Three Dots (…).
  2. Select More > Discard Check-out (or Check in).
  3. Confirm the prompt. The file will immediately become editable by the team.

Maintaining Governance and User Hygiene

File locking issues often stem from broader permission and user management issues, such as disabled or deleted employees leaving checked-out files behind. Ensuring regular access reviews keeps your document libraries clean.

To automatically audit user access, identify orphaned accounts, and clean up legacy site permissions, use SPClean—the ultimate PowerShell toolkit for SharePoint Online permission management.

Programmatically Unlocking Files via PnP PowerShell

Site Administrators can check for checked-out files and discard locks programmatically using PnP PowerShell:

$ClientId = "Your-client-id" # Your Entra ID App Client ID
$SiteUrl = "https://yourtenant.sharepoint.com/sites/Finance"

# Connect interactively with modern authentication
Connect-PnPOnline -Url $SiteUrl -Interactive -ClientId $ClientId

# Find all checked-out files in the Documents library
$checkedOutFiles = Get-PnPListItem -List "Documents" | Where-Object { $_.FieldValues.CheckoutUser -ne $null }

foreach ($item in $checkedOutFiles) {
    Write-Host "Unlocking file: $($item.FieldValues.FileRef)" -ForegroundColor Yellow
    # Undo check-out to release lock
    Undo-PnPFileCheckout -Url $item.FieldValues.FileRef
}

Write-Host "All locked files cleared!" -ForegroundColor Green

Best Practices Comparison Table

ScenarioRoot CauseRecommended Fix
Desktop App CrashOrphaned 10-minute leaseWait 10 mins or edit in Web Browser
Manual Check-OutExplicit Check-Out flag setUse “Discard Check-Out” in file menu
Macro Workbooks (`.xlsm`)Unsupported Co-Authoring featureConvert to `.xlsx` or use Excel Web

By understanding lease timeouts and leveraging Web Apps, you can eliminate file lock bottlenecks and keep team collaboration moving smoothly!

© 2026 M365 Automation. All rights reserved. Designed for M365 Admins.