I have some code for masking password when a macro is run to get data from a database. It works, but for each run, I have to input the password and that can be really a pain and many users complain about it.
This is the code I have that when a user presses the button to run the macro:
and this is the code from the userform that opens up to imput password and it also masks the password:
Private Sub butCancel_Click() Unload Me End Sub Private Sub butOK_Click() Me.Hide End Sub Private Sub UserForm_Initialize() butOK.Default = True End Sub Function ValueEntered(promptString As String, Optional titleString As String, Optional defaultString As String, Optional PassChr As String) Dim aForm As Object Dim ufCount As Long ufCount = UserForms.Count With Me .Label1.Caption = promptString .Caption = titleString .TextBox1.Text = defaultString .TextBox1.PasswordChar = Left(PassChr, 1) .Show End With ValueEntered = UserForm1.TextBox1.Text Unload UserForm1 End Function
The login I have in a cell that the user fill in and that stays there, but I would prefer to be able to have it in the the userfom that pops up (just no clue how to solve that)
There are various sheets in the workbook that needs to pass also the login and password to use the macros.
If the workbook could keep in memory the login and password till it closses, well that would be really nice.