Hi all
Can you help, i have used the code below. What i am looking to do is turn it around so the array is a list of people that are allowed to save the sheet.
Also needed adding to the code i would like, once someone who is not allowed to save the file, trys and gets the message box saying they are not allowed to save the file. When they click OK the file will close without saving.
Hope you guys can help its driving me mad trying.
Thanks in advanced
don
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim UName As String
Dim NoSave, UFind As Variant
'Get the name of the user logged on the computer
UName = Environ("Username")
'List of names that can NOT use the save function
NoSave = Array("user1", "user2", "user3")
On Error Resume Next
UFind = Application.WorksheetFunction.Match(UName, NoSave, 0)
If Err = 0 Then
Cancel = True
MsgBox ("You are not authorized to save")
End If
End Sub
Can you help, i have used the code below. What i am looking to do is turn it around so the array is a list of people that are allowed to save the sheet.
Also needed adding to the code i would like, once someone who is not allowed to save the file, trys and gets the message box saying they are not allowed to save the file. When they click OK the file will close without saving.
Hope you guys can help its driving me mad trying.
Thanks in advanced
don
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim UName As String
Dim NoSave, UFind As Variant
'Get the name of the user logged on the computer
UName = Environ("Username")
'List of names that can NOT use the save function
NoSave = Array("user1", "user2", "user3")
On Error Resume Next
UFind = Application.WorksheetFunction.Match(UName, NoSave, 0)
If Err = 0 Then
Cancel = True
MsgBox ("You are not authorized to save")
End If
End Sub