Check if an Excel or Word file is "read only"????

R

Robert Crandal

Are there any VBA functions I can call from an Excel file that
will help me determine if a particular Excel 2007 or Word 2007
is currently in "read only" status? In other words, I need to
test if an Excel or Word file is opened or in use by another user??

I would like to know any or all methods to achieve this.

Thank you everyone!

Robert
 
H

Harald Staff

Hi Robert

Sub test()
MsgBox ActiveWorkbook.ReadOnly
MsgBox ActiveWorkbook.WriteReserved
MsgBox ActiveWorkbook.WriteReservedBy
End Sub

This needs the file to be open. If you want to see if a file is in use
before opening it, there is usually a similarly named temp file in the same
folder if someone else uses the file. Test opening and closing with a file
explorer window open.

Best wishes Harald
 
R

Robert Crandal

Do you know how to check the read only status on a
file that is NOT the ActiveWorkbook? For example,
I will be using a file named "mydata.xlsm". While using
this file, I want to run a macro to test whether a file named
"groupdata.xlsm" is open or being used by another user.

Also, if I want to see if a file is in use BEFORE opening it,
does that mean I need to check for the presence of a hidden
temp file in the same folder with a similar name? Is there a
reliable VBA function for this?

Thank you Harald!
 
H

Harald Staff

MsgBox Workbooks("mydata.xlsm").ReadOnly
'and so on

and Yes, and No, not to my knowledge, you must write it.

Best wishes Harald
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top