Userform as auth method not working Excel [closed]

0

Hey guys I think it's probably a very simple awnser but I'm not finding it.

I made a simple user form that takes a user and a password and pops up before the workbook is visible as a simple auth method. The problem is that I want to hide the VBA project as it contains the password and the user.

When I do the usual and protect it with a password and select "Hide project for exhibition" the userform stops popping up and working.

How do I get over this problem.

Please Help.

I have this macro that should run when the user opens the workbook:

Private Sub Workbook_Open()

Application.Visible = False
UserForm1.Show

End Sub

The called UserForm1:

Private Sub cmd_cancelar_Click()


Unload Me

ThisWorkbook.Close


End Sub

Private Sub cmd_ok_Click()

If tb_login = "admin" And tb_senha = "1234" Then

    Unload Me 'fecha o formulário
    Application.Visible = True

Else

    MsgBox "Usuário ou Senha Incorretos", vbCritical, "Senha Incorreta"
    ThisWorkbook.Close

End If

End Sub


Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)

If CloseMode = vbFormControlMenu Then

    Cancel = True

End If

End Sub
    
asked by anonymous 05.10.2017 / 23:42

0 answers