sandysharma
Member
Hi All,
Need to know if we have any before workbook open sort of event or trick....
I have a file that I want to restricted to specific user....and any other user tries to open that file he should be restricted....he should not be even see any of the sheets....I have following coding which works well but other users are able to see the sheet...Please help..
Need to know if we have any before workbook open sort of event or trick....
I have a file that I want to restricted to specific user....and any other user tries to open that file he should be restricted....he should not be even see any of the sheets....I have following coding which works well but other users are able to see the sheet...Please help..
Code:
Private Sub Workbook_Activate()
Dim bz As Boolean
'MsgBox Environ("username")
With ThisWorkbook
bz = Environ("username") = "S83" Or Environ("username") = "S81" Or _
Environ("username") = "H41"
If bz = False Then
MsgBox Environ("username") & " you are not authorized to open this file"
ThisWorkbook.Close
End If
End With
End Sub
Last edited by a moderator: