Using a batch file to open a Word document that someone is using [Solved/Closed]

Report
Posts
1004
Registration date
Saturday January 17, 2015
Status
Moderator
Last seen
November 27, 2020
-
Posts
47403
Registration date
Monday February 1, 2010
Status
Moderator
Last seen
November 27, 2020
-
Hi All,

I know I said I'd steer away from programming, but here I am again - stuck on a "simple" task ... As always your help would be appreciated.

What I have done so far is to write a batch file that opens a Word document (Office 2007). The document title changes every day and I am proud that I got it working ... until today ...

The issue today was that someone else on the network has the file open. Usually the file opens when using the
START %target%
(remember the %target% is made up of previous script to make todays document open it is in the form of a path so could easily be written as
START C:\Logs\TodaysLog
)

However when someone else has the file open and I run the script I get "The process cannot access the file because it is being used by another process."

In this situation how can I get it to open a read only version of the document? I have tried with
START /r %target%
and
START %target% /r
but both fail.

I have the ERRORLEVEL bit to check its errored working so only need the bit to get the document open in "Read Only " mode.

Any ideas please guys?
Thanks in advance.

2 replies


Upgrade to Office 365. All can make real time changes on an open document.

I understand the cost will make this unattainable. A word cannot be opened in notepad, as the formatting is inline, and the notepad cannot discern between formatting and "content".


Posts
1004
Registration date
Saturday January 17, 2015
Status
Moderator
Last seen
November 27, 2020
113
A nice idea, but the Company wont go for it - we are stuck with what we have and have to make our own workarounds for what we need (thats why I do so much of this stuff I dont fully understand, but its a great way to learn!)

Also, I dont need to be able to change stuff - just read it ... if I were opening it normally I could open it as a read only, but am struggling with this in a batch file.

Thanks anyway, but got any more ideas?
Posts
1004
Registration date
Saturday January 17, 2015
Status
Moderator
Last seen
November 27, 2020
113
Awwww - What a shame ... I googled "word command line switches" and found this site:

https://support.office.com/en-us/article/Command-line-switches-for-Microsoft-Office-products-079164CD-4EF5-4178-B235-441737DEB3A6

According to Microsoft it seems there is no switch to enable this to happen - but surprisingly there is one for Excel, Powerpoint ...

Oh well - I'll just have to get off my bum and ask people to close their copy ... or just do it the old way and double click on the file itself ...

Thanks for your help on this ac3mark.
Posts
47403
Registration date
Monday February 1, 2010
Status
Moderator
Last seen
November 27, 2020
9,091
Mark is a gem and a future president of some kind!

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!