Hi Rich, try putting this in the ThisWorkbook module
Private Sub Workbook_Open()
Dim objNet As Object
Dim Msg As String
Set objNet = CreateObject("WScript.NetWork")
Select Case objNet.UserName
Case Is = "Clve", "richard.galvin", "John", "Mary"
Call Rich2
Case Else
Call Rich1
End Select
End Sub
And put the code below in a standard module
Sub Rich1()
Dim wSheet As Worksheet
Dim Pwd As String
Application.ScreenUpdating = False
Pwd = InputBox("Enter your password to unprotect all worksheets", "Password Input")
On Error Resume Next
For Each wSheet In Worksheets
wSheet.Unprotect Password:=Pwd
Next wSheet
If Err <> 0 Then
MsgBox "For access please contact " & _
"This Person", vbCritical, "Please Try Again"
End If
On Error GoTo 0
Application.ScreenUpdating = True
ThisWorkbook.Save
End Sub
Sub Rich2()
Dim myPassword As String
Dim wSheet As Worksheet
Dim Rly As Integer
Application.ScreenUpdating = False
Rly = MsgBox("You have been granted access. To unlock all sheets press Yes", 68)
If Rly = 6 Then
myPassword = "Pwd"
On Error Resume Next
For Each wSheet In ActiveWorkbook.Worksheets
wSheet.Unprotect Password:=myPassword
Next
Else
Exit Sub
End If
Application.ScreenUpdating = True
End Sub
Please note: You should really take the solved off the post if you are adding another question.
Bookmarks