automating (alt & f11)

P

pswanie

my previous posting was not clear i think...

what can i add to a command so that when i click it, it checks that textbox1
got "mypass" and then run the sub

i have a textbox on a userform and a commandbutton1.
the aplication (excell workbook) is set to visible = valse

click commandbutton1 go and check if textbox1 contain "mypass"
commandbutton1 make the application visible = true and unload userform1.

then i can get to my macros etc..
i got this.


Private Sub CommandButton5_Click()


Application.Visible = True
Unload UserForm1


End Sub
 
P

Per Jessen

I think this is what you need.

Private Sub CommandButton5_Click()

If Me.textbox1.Value = "mypass" Then
Application.Visible = True
Unload UserForm1
End If

End Sub

//Per
 
R

Rick Rothstein \(MVP - VB\)

Try this...

Private Sub CommandButton5_Click()
If TextBox1.Text = "mypass" Then
Application.Visible = True
Unload UserForm1
End If
End Sub

If you are doing what I think you are doing, you should know (at least I'm
pretty sure that) your password will be embedded in the saved workbook as
plain text; viewable with a plain text editor like Notepad. True, someone
would have to know where to look, but it might be easy to locate. You might
want to encrypt it a little bit to make it harder to find. One way, perhaps,
would be to mix it in between other characters (maybe locating each letter
as the 3rd character in a much bigger string of characters) and run a loop
to pick them out.

Rick
 
P

pswanie

great idea.... jip im aware that its easy to crack that..

how would i go about to use that loop idea?
 
P

pswanie

i needed to add that when userform unload and application vissible hapens.
would it be possible to automate the alt & F11 keystroke?
 
R

Rick Rothstein \(MVP - VB\)

Try this (the password is still mypass)...

Private Sub CommandButton5_Click()
Dim X As Long
Dim PW As String
Const HiddenPassword = "@32m )#yeX*p p!a64bs ##sdf2"
For X = 4 To Len(HiddenPassword) Step 4
PW = PW & Mid(HiddenPassword, X, 1)
Next
If TextBox1.Text = PW Then
Application.Visible = True
Unload UserForm1
End If
End Sub

You can change the starting spot in for you password in the HiddenPassword
constant, and also vary the number of characters between the letters of your
password, you just have to adjust the starting point and Step values in the
For-Next loop. This way, if someone looks, they will only see @32m )#yeX*p
p!a64bs ##sdf2 and not your actual password. Of course, this is an extremely
simple encryption scheme, but it should suffice for normal situations. Note
that if you use a regular word or phrase, it might still be discoverable by
"prying eyes", but if you mix punctuation marks into your "real" password,
it should be harder to find in random mix of letters.

Rick
 
R

Rick Rothstein \(MVP - VB\)

Put this right after your "Unload UserForm1" statement...

Application.OnKey "%{F11}"

Rick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top