Detect if Excel file is "read only"???

R

Robert Crandal

If I open an Excel file which someone is currently using, Excel
will display a caption in the title bar that says "read only". Excel
is probably telling me that the file is read only because another
user currently is using the file.

My question is, does Excel have a function (or can I create
my own) which returns TRUE if the file is "read only" or
FALSE otherwise??? I'm mostly interested in a function
that returns TRUE if Excel displays the "read only" caption due
to the file's state of being in use.

thank you
 
G

Gary Keramidas

if activeworkbook.ReadOnly = true then
'do something
else
'do something else
end if
 
B

Barb Reinhardt

I've put something in the "Workbook_Open" procedure in the "ThisWorkbook"
module to check to see if the workbook is read only. The only difference
is that I'd use
If ThisWorkbook.Readonly then
'Do something
Else
'Do something else
end if

That way you know immediately when you open the workbook that it's read
only. Of course, macros need to be enabled for this to work.
 
B

Bill McMurray

Robert,

I am just an old, gray-haired teacher. A very useful lesson for my
students is to learn self-instruction and not rely on others if it is not
necessary. In other words, it would behoove them to research information
themselves. It can be a powerful tool, especially today in the age of the
internet.

I have not responded before in this NG but I do frequent the threads so I
may learn more. What I have noticed with many of your questions is that the
answers are right at *your* fingertips but you rely on others to provide
them for you.

In this case, if you simply searched VBA help for "readonly", you would have
found "workbook.readonly property" which is exactly what Mr. Keramidas
provided you with. You could have had your answer in a matter of seconds
instead of minutes.

In addition, a Google search for
http://www.google.com/search?hl=en&...adonly&rlz=1R2DKUS_enUS352&aq=f&aqi=&aql=&oq=
resulted in the first hit http://support.microsoft.com/kb/153058

I hope you accept this advice (from a teacher of 42 years) in the manner
intended.

Bill
 
R

Robert Crandal

Hi Bill,

But, if nobody relied on you and merely used Google for
their information, then you would be out of a teaching job,
wouldn't you?? ;)

I'm just being a smart ass here, haha. No offense is intended
to ya! Thanks for the advice though.

Robert
 
B

Bill McMurray

Robert,

You're alright in my books.

The good news for teachers is that there are just some things you *can't*
learn through the internet.

Cheers from an old dinosaur.

Bill
 

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