Programmatically determining if workbook is opened as Read Only

  • Thread starter Thread starter Barb Reinhardt
  • Start date Start date
B

Barb Reinhardt

I have a data extraction macro that I run monthly and it takes a while to
run, so I periodically open it in another Excel instance as Read Only during
the extraction to get an indication on how much is left to extract.
Unfortunately, I also have a workbook open event that asks if I want to run
the macro, which fires whether it's read only or not. I don't want this
message displayed if the workbook is opened as read only. Is there some way
to do that?

Thanks,
Barb Reinhardt
 
I found what I need. It's ActiveWorkbook.ReadOnly. Now why didn't I think
of that before I posted this? :)

Thanks anyway!
Barb Reinhardt
 
Seems to work OK

Private Sub Workbook_Open()
If ThisWorkbook.ReadOnly = True Then
MsgBox "This book is read only."
Else
MsgBox "Run"
'run your macro
End If
End Sub

Mike
 
Tom,

Does it work that way when I open a new Excel instance and open the workbook
from the list of last edited files?

Thanks,
Barb Reinhardt
 
Yes. Once you have the mouse over the filename, hold down the shift key
until it has opened.
 

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

Back
Top