Hi
Some sugestions for OP.
Instead keeping allowed users in text file, write them into this Open event,
p.e into an array - you can define and fill it at top of procedure, so it'll
be easy to edit in future. P.e.
Private Sub Workbook_Open()
Dim arrUsers(3) As Variant
Dim intUsers As Integer, i As Integer
Dim usrname As String
arrUsers(1)="First user"
arrUsers(2)="Second user"
arrUsers(3)="Third user"
intUsers=3
usrname = Environ("Username")
For i=1 To intUsers
If arrUsers(i) = usrname Then
MsgBox "Hello " & usrname & " OK to open file"
GoTo 100
End If
Next i
MsgBox " Not authorised"
ThisWorkbook.Close savechanges:=False
100:
End Sub
To avoid the user bypassing macros, make all essential sheets very hidden,
with only a dummy sheet with warning about unauthorizaed access visible. Add
a couple of code rows at end of sub (before End Sub), which make right
sheets visible and hide the dummy sheet, when allowed user opens the file.
And the last step will be to protect your VBA-Project with password.
Of course a determinated and skillfull user can hack it without any
problems, but not an average Joe