View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Paul D.[_2_] Paul D.[_2_] is offline
external usenet poster
 
Posts: 18
Default test sheet for protection

I put this code in the Workbook BeforeClose Event to make sure the Sheet is
protected before I close the App. Works perfectly when I try to close the app
using the Close Button at top right of the window. When I close the App using
the code Application.Quit in a close button I put into a form,
ActiveSheet.ProtectContents is always False. If I use
Sheets("name").ProtectContents, same thing always False.

Does that make sense, is there a work around?

"Mike" wrote:

You were nearly there, try this:-

Sub isitprotected()
If ActiveSheet.ProtectContents = True Then
MsgBox ("Protected")
Else
MsgBox ("Unprotected")
End If
End Sub

Mike

"David" wrote:

Been racking my brains again...
Tried:
On Error Resume Next
If Not ActiveSheet.Protection Is Nothing Then
MsgBox "sheet is protected"
Else: MsgBox "Sheet is not protected"
On Error GoTo 0
End If
...but alas, no joy, please help