Using a batch file to open a Word document that someone is using

Solved/Closed
BrianGreen Posts 1005 Registration date Saturday January 17, 2015 Status Moderator Last seen September 30, 2021 - May 28, 2015 at 01:20 PM
Ambucias Posts 47310 Registration date Monday February 1, 2010 Status Moderator Last seen February 15, 2023 - May 28, 2015 at 05:53 PM
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.
Related:

2 responses

Blocked Profile
May 28, 2015 at 05:09 PM
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".


0
BrianGreen Posts 1005 Registration date Saturday January 17, 2015 Status Moderator Last seen September 30, 2021 149
May 28, 2015 at 05:18 PM
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?
0
BrianGreen Posts 1005 Registration date Saturday January 17, 2015 Status Moderator Last seen September 30, 2021 149
May 28, 2015 at 05:45 PM
Awwww - What a shame ... I googled "word command line switches" and found this site:

https://support.microsoft.com/en-us/office/command-line-switches-for-microsoft-office-products-079164cd-4ef5-4178-b235-441737deb3a6?ui=en-us&rs=en-us&ad=us

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.
0
Ambucias Posts 47310 Registration date Monday February 1, 2010 Status Moderator Last seen February 15, 2023 11,163
May 28, 2015 at 05:53 PM
Mark is a gem and a future president of some kind!
0