tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,832
- Office Version
- 365
- 2019
- Platform
- Windows
I have created a program whereby it looks for the users login and sets that to be the password.
It works perfectly fine on my PC but when distributed to users, it fails here:
Can someone please tell me why? The only difference between my PC and my users is when I open the program, it does NOT ask me to Enable content but it does on my users' PC.
This is in ClsVariables
[/code]
It works perfectly fine on my PC but when distributed to users, it fails here:
Code:
Sheet1.Unprotect Password:=MyPassword.Password
Can someone please tell me why? The only difference between my PC and my users is when I open the program, it does NOT ask me to Enable content but it does on my users' PC.
Code:
Option Explicit
Dim PasswordArray() As Variant
Public Sub Workbook_Open()
With Me
Call .SetPassword
End With
Set MyAuthorisedUser = New ClsVariables
MyAuthorisedUser.AuthorisedUser = False
Dim PasswordElementsCounter As Integer
For PasswordElementsCounter = LBound(PasswordArray, 1) To UBound(PasswordArray, 1)
If ModFunctions.GetUsername = PasswordArray(PasswordElementsCounter, 1) Then
MyAuthorisedUser.AuthorisedUser = True
Exit For
End If
Next PasswordElementsCounter
Sheet1.Unprotect Password:=MyPassword.Password 'FAILS HERE
End Sub
Sub SetPassword()
Set MyPassword = New ClsVariables
MyPassword.Password = ModFunctions.GetUsername
End Sub
Sub UsersList()
PasswordArray = wksAuthorisedUsers.Cells(7, 1).CurrentRegion.Value
End Sub
This is in ClsVariables
Code:
Option Explicit
Private pPassword As String
Private pAuthorisedUser As Boolean
Public Property Let Password(ByVal PWord As String)
pPassword = PWord
End Property
Public Property Let AuthorisedUser(ByVal AUser As Boolean)
pAuthorisedUser = AUser
End Property
[/code]