Vernon Reed
Vernon Reed

Reputation: 33

How to check the CURRENTLY OPEN excel file is open in read only mode?

OPENING: I've been digging around for a long time looking at some of the answers to the questions here. I hope my Google-fu isn't getting rusty but I couldn't find anything helpful. I've tried what I have found with no luck.

PROBLEM: I have a document that is used by more then one user. The short vesion is the document ends up in Read Only mode one way or another and they forget its Read Only (or they just press the Okay button and dont read the warning). You can still operate everything in the worksheet as normal.

Through normal operation of the worksheet and the Macros the Workbook will auto save on completion of the Macro.

Is there any way to check (with the worksheet open) that the version you have is open in Read Only mode? I'd like to introduce code to prevent the use of the main function (disable the workbook macro) while using it in Read Only.

IDEAL SOLUTION: Have a function I could call to check the Read Only Status of the workbook.

Example:

Public Function ReadOnlyMode () as Bool

'Code that I don't know how to write for the funtion
return True/False

End Function

Upvotes: 3

Views: 3640

Answers (1)

QHarr
QHarr

Reputation: 84465

Use the following to test

If ActiveWorkbook.ReadOnly Then  'If True

See .ReadOnly property description.

Workbook.ReadOnly Property (Excel)

Returns True if the object has been opened as read-only. Read-only Boolean .

Upvotes: 4

Related Questions