Fix SharePoint Word Document Locked When Renaming with CSOM
Question details
Users encounter a 'locked for shared use' error when attempting to rename or interact with a SharePoint Word document using CSOM, even when no one is actively editing the file.

- Product
- Microsoft Word / SharePoint
- Device & OS
- not provided
- Scenario
- Creating, modifying, or renaming a document in a SharePoint library via CSOM (Client-Side Object Model) scripts or applications.
- Observed behavior
- The file incorrectly returns a locked error. Document properties show LockedByUser is present despite CheckedOutByUser being None, preventing CSOM operations.
Ensure that no background browser sessions or background Office applications have the document actively open, and verify your script has properly closed previous streams before attempting a rename.
Clear the Microsoft Word Document Cache
If the document was originally created, opened, or synced using the desktop Word application, residual background cache files can cause false lock states in SharePoint.
Often, SharePoint lock errors occur because the local Microsoft Office Upload Center or Word cache maintains a background connection to the file. Clearing this cache forces the application to release its hold on the document.
Launch the Microsoft Word desktop application. Click on 'File' in the top-left corner, then select 'Options' at the bottom of the menu.
In the Word Options dialog box, click on the 'Save' tab in the left-hand navigation pane.
Scroll down to the 'Cache Settings' section. Click the 'Delete cached files' button. Once cleared, click 'OK' to save the changes and test your CSOM script again.

Investigate CSOM Script and Server Locks
If the document was strictly created and renamed using CSOM without desktop Word involvement, the lock may be handled at the server or script execution level.
Try WPS Office for Seamless Document Management
If you frequently encounter frustrating file locks or complex caching issues in Microsoft Office and SharePoint, consider switching to WPS Office. It provides a lightweight, highly compatible alternative for creating, editing, and managing your everyday documents.
- 1. Download WPS Office: Visit the official WPS website to download the free, lightweight installer for your operating system.
- 2. Open Your Document: Launch WPS Writer and simply drag and drop your .docx files into the workspace to start editing.
- 3. Save and Share: Save your work seamlessly in standard formats that are universally compatible without worrying about complex server lock issues.

Frequently Asked Questions
Why does SharePoint say my Word document is locked for shared use?
This usually happens when the Office Upload Center, local Word cache, or an improperly closed CSOM session maintains a background connection to the file, making SharePoint think it is still actively being edited.
How long does a SharePoint document lock last?
If a document is locked due to an unexpected crash or closed session without a proper release, the SharePoint server typically releases the lock automatically after an idle timeout period of about 10 minutes.
Does clearing the Word cache delete my files?
No, clearing the cache in Word's Save options only removes temporary background files used for syncing with SharePoint or OneDrive. It does not delete your actual saved documents or data.




