Password problem

tiredofit

Well-known Member
Joined
Apr 11, 2013
Messages
1,832
Office Version
  1. 365
  2. 2019
Platform
  1. 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:

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]
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
You don't appear to have a Property Get procedure so I don't see how it could work.
 
Upvote 0
I do have a Get property but didn't post it here because stepping into the code, it breaks before it hits the Get property.

Code:
Public Property Get Password() As String
    Password = pPassword
End Property
 
Upvote 0

Forum statistics

Threads
1,214,946
Messages
6,122,401
Members
449,081
Latest member
JAMES KECULAH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top