PDA

View Full Version : [SOLVED] "Read Only" workbook



outrider
01-26-2005, 02:52 PM
If someone opens a read-only copy of a workbook and then tries to run the macros, is it possible to detect that it is a read-only copy and display a warning message. When the user clicks the "OK" button in the warning, the application closes without any other alerts being displayed?


Thanks

Jacob Hilderbrand
01-26-2005, 03:10 PM
Try this.


Option Explicit

Sub CheckReadOnly()
Dim MyResponse As VbMsgBoxResult
If ActiveWorkbook.ReadOnly = True Then
MyResponse = MsgBox("This workbook is read only. Do you want to close?", _
vbYesNo, "Read Only")
If MyResponse = vbYes Then
ActiveWorkbook.Close False
End If
End If
End Sub

outrider
01-27-2005, 02:02 AM
Thanks for the quick response Jake.
It works very well in my workbook.

Jacob Hilderbrand
01-27-2005, 02:04 AM
You're Welcome :beerchug:

Take Care