'----------------------------------------------------------------------------
Sub zProtect_All(bProtect)
'
' ProtectAll Macro
' Macro recorded 8/23/2005 at TSI
' Help over the net from a guy posting an Irish flag
' Prompting 4 pwd suggested by Crimson B1ade in SEP08
'
Dim ws As Worksheet
Dim cPwd As String
Dim bProtected As Boolean, bUpdating As Boolean
'
cPwd = InputBox(Prompt:="Enter password to change protection status of worksheets: ", _
Title:="Password Input")
'Preserve initial worksheet status; maybe store in an array or Public mVars?
bProtected = ActiveSheet.Protect
bUpdating = Application.ScreenUpdating
Application.ScreenUpdating = False
If bProtect Then
For Each ws In ActiveWorkbook.Worksheets
ws.Protect Password:=cPwd, DrawingObjects:=True, Contents:=True, Scenarios:=True, UserInterFaceOnly:=True
Next ws
ActiveWorkbook.Protect Password:=cPwd, Structure:=True, Windows:=False
Else
'ActiveWorkbook.Unprotect Password:="cPwd"
For Each ws In ActiveWorkbook.Worksheets
ws.Unprotect Password:=cPwd
Next ws
End If
Application.ScreenUpdating = bUpdating
End Sub
'----------------------------------------------------------------------------