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

BrianGreen 963 Posts Saturday January 17, 2015Registration dateContributorStatus July 17, 2018 Last seen - May 28, 2015 at 01:20 PM - Latest reply: Ambucias 53262 Posts Monday February 1, 2010Registration dateModeratorStatus July 19, 2018 Last seen
- 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.
See more 

4 replies

ac3mark 9964 Posts Monday June 3, 2013Registration dateModeratorStatus July 19, 2018 Last seen - May 28, 2015 at 05:09 PM
0
Thank you
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".


BrianGreen 963 Posts Saturday January 17, 2015Registration dateContributorStatus July 17, 2018 Last seen - 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?
BrianGreen 963 Posts Saturday January 17, 2015Registration dateContributorStatus July 17, 2018 Last seen - May 28, 2015 at 05:45 PM
0
Thank you
Awwww - What a shame ... I googled "word command line switches" and found this site:

https://support.microsoft.com/en-us/kb/210565

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.
Ambucias 53262 Posts Monday February 1, 2010Registration dateModeratorStatus July 19, 2018 Last seen - May 28, 2015 at 05:53 PM
Mark is a gem and a future president of some kind!