Unlock a MS Word file while editing

When an MS Word file is in use, I mean open and being edited. It seems to lock the file, so nothing else can be done to it. Also, I see the temp file it makes in the directory. My question is, can this be overridden or changed so that another application can read the file's contents?

For example, if I have a file open in Word and I want to import (Place) it into Adobe InDesign, the dialogue will complain that the file is not ready. This is the case even if you have just saved it.

There is a program called LockHunter that I originally learned about here from a member on the Opus forum that can do this unlocking. It was so long ago I do not remember which member. It also tells you what is locking the file, something like this.

Process ID: 4928
Command Line: "C:\Program Files\Microsoft Office\Root\Office16\WINWORD.EXE" /n "C:\Temp\myTest.docx

LockHunter does not seem to have a command line version. So I do not know if it will be able to be automated. Does anybody know of a command line way to do simllar

Once I have the process ID I wonder what I can do with it. Because ultimately, I want to automate this process and make it silent. To be clear I mean not have to interact with any interface and mouse clicks.

Of course, I do not want to corrupt the data in the file. Does anybody know how? Thank You

Don’t use unlocking tools except as a last resort. If Word has a lock on the file and you want it to release it, the only safe way is to close the file in Word.

Word has an automation (scripting) interface which would let you write a script to close a specified file via the command line, if you need that rather than closing the file via Word’s UI.

I do see a command line option for LockHunter... I did not find the first time. How ever any knowledge about this is welcome. Thanks

LockHunter Command line options

Yes, don’t use it. :slight_smile: Unless random data corruption is your aim, at least.

This means the Word file will not be available for editing until reopened, correct?

Yes. The same would be true of any method you used, except if you used an unlocker tool Word might still think the file is open and then fail to save any changes, or crash, or write the changes into a random other file (if the handle value was reused by a new file).