Unlock Office Files for Upload
Transparently copies locked Office files (docx, xlsx, pptx, etc.) to a temp location when an upload or send is attempted while they're open in Word/Excel/PowerPoint. The OS deletes the copy automatically via FILE_FLAG_DELETE_ON_CLOSE.
Author: Loerei
When you try to upload or attach a .docx, .xlsx, .pptx (or their legacy
variants) while the file is open in Word/Excel/PowerPoint, you get:
This file is in use. Enter a new name or close the file that's open in
another program.
This mod silently intercepts that failure in the uploading process (Chrome,
Edge, Outlook, Teams, Discord, etc.), makes a temporary copy of the file, and
redirects the open call to the copy. The OS deletes the copy automatically when
the caller closes the handle (FILE_FLAG_DELETE_ON_CLOSE) — even on process
crash or abnormal exit.
What you get: The uploader receives the last-saved version of the file with
no prompts and no need to close Word first.
Known Limitations
Unsaved edits not included. The copy reflects the last saved state.
Unsaved in-memory edits in Word are not captured — this is inherent to how
Windows file locking works.
Deny-read locks not bypassed. The redirect only works when the existing
lock permits shared reads (Word's usual FILE_SHARE_READ lock). Legacy
formats (.doc, .xls, .ppt) held by some applications may deny all reads
outright, in which case CopyFileW also fails and the mod re-surfaces the
original sharing violation error.
Scope Note
The mod injects into all processes (required since the uploader can be any
app). SearchIndexer.exe and explorer.exe are excluded via @exclude.
Session 0 (system service) processes are skipped at init time. The
CreateFileW hook has near-zero overhead on the success path — it returns
immediately when the original call succeeds. A thread_local reentrancy
guard ensures that CopyFileW's own internal CreateFileW calls do not
re-enter the hook logic.