Check if activesheet is protected

  • Thread starter Thread starter freseh
  • Start date Start date
F

freseh

Hello Everyone!

I have a small problem that needs a simple solution.
How do I check with VBA if my activesheet is password protected?

What I want to have is a macro that protect if it's unprotected and
vice verse.

And this doesn't work, the red text must be something else :

If ActiveSheet.Protect.Enabled = False Then
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True, Password:="bossboss"
Else
ActiveSheet.Unprotect Password:="bossboss"
End If

Thanks in advance for your help!
 
Freseh

change,

If ActiveSheet.Protect.Enabled = False Then

to

If ActiveSheet.ProtectContents = false Then

That should do the trick

HTH
 
Back
Top