After some private exchanges:
Option Explicit
Private Sub CommandButton1_Click()
'unprotect
Application.ScreenUpdating = False
If Worksheets("sheet2").ProtectContents _
Or Worksheets("sheet2").ProtectDrawingObjects _
Or Worksheets("sheet2").ProtectScenarios Then
Worksheets("sheet2").Activate
On Error Resume Next
Application.Dialogs(xlDialogProtectDocument).Show
On Error GoTo 0
Else
MsgBox "already unprotected"
End If
If Worksheets("sheet2").ProtectContents _
Or Worksheets("sheet2").ProtectDrawingObjects _
Or Worksheets("sheet2").ProtectScenarios Then
MsgBox "Please provide the correct password when prompted " & _
"when you try this again."
End If
Me.Activate
Application.ScreenUpdating = True
End Sub
Private Sub CommandButton2_Click()
'protect
Application.ScreenUpdating = False
If Worksheets("sheet2").ProtectContents _
Or Worksheets("sheet2").ProtectDrawingObjects _
Or Worksheets("sheet2").ProtectScenarios Then
MsgBox "already protected"
Else
Worksheets("sheet2").Activate
Application.Dialogs(xlDialogProtectDocument).Show
End If
If Worksheets("sheet2").ProtectContents _
Or Worksheets("sheet2").ProtectDrawingObjects _
Or Worksheets("sheet2").ProtectScenarios Then
Else
MsgBox "The worksheet is not protected"
End If
Me.Activate
Application.ScreenUpdating = True
End Sub
gavmer wrote:
Hi Rog,
Thanks for the reply but i should pprovide more info. The buttons are
actually on a separate sheet. Does this affect the manual process of
protecting/unprotecting sheets??
Cheers!!!!!!
--
gavmer
------------------------------------------------------------------------
gavmer's Profile: http://www.excelforum.com/member.php...fo&userid=6662
View this thread: http://www.excelforum.com/showthread...hreadid=262682
--
Dave Peterson