Locking A sheet
I am using a Custom Button to lock/unlock a sheet
If ActiveSheet.ProtectContents = True Then
ActiveSheet.Unprotect
With Application.CommandBars.ActionControl
.Caption = "Protect Sheet"
End With
Exit Sub
End If
With Application.CommandBars.ActionControl
.Caption = "Un Protect Sheet"
End With
ActiveSheet.Protect
if the sheet is unlocked the code will work and change the button text but
when I go to relock the sheet the line of code to change the caption to
unlock sheet errors out with
Object Variable or With block variable not set
why does it work outsied the if statement and not inside
thanks
|