Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Password Userform help !!!!
Sub Sunselect()
Dim PassStr As String PassStr = InputBox("Enter Password Please", "My Password Prompt") If PassStr = "Manager" Then Sheets("Sun").Select Range("A11").Select Else MsgBox "Wrong Password Entered" End If End Sub Am currently using this to ask for a password before allowing people to view the sheet, but would prefer to use a usrform, i know how to creat and asign the form, but am not sure of the exact text as fairly new to userforms, Prefer to have password char as ******** when typed and have been told this is not possible with input box. Any help |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Password Userform help !!!!
I've had managed to use the following code within a userform textbox change
function, that will read characters as they are typed into the textbox and add them to a temporary password variable 'tmpPWord', then replace the typed character with a * for display in the textbox. Therefore, the user will only see a row of *'s in the textbox, yet the actual password is stored in temporary variable 'tmpPWord'. Try it out! I hope it works for you. Private Sub TextBoxPassword_Change() Dim repeatCancel As Boolean Dim i As Integer Dim tmpTextBoxText As String tempWord = "" If Len(TextBoxPassword.Value) < Len(dispPassWord) Then dispPassWord = Left(dispPassWord, Len(dispPassWord) - 1) tmpPWord = Left(pWord, Len(tmpPWord) - 1) Else If Right(TextBoxPassword.Value, 1) < "*" Then If Len(TextBoxPassword.Value) 1 Then tempWord = Right(TextBoxPassword.Value, 1) dispPassWord = dispPassWord & "*" Else tempWord = TextBoxPassword.Value dispPassWord = "*" End If tmpPWord = tmpPWord & tempWord TextBoxPassword.Value = dispPassWord End If End If End Sub Regards John Cleese K1KKKA wrote: Sub Sunselect() Dim PassStr As String PassStr = InputBox("Enter Password Please", "My Password Prompt") If PassStr = "Manager" Then Sheets("Sun").Select Range("A11").Select Else MsgBox "Wrong Password Entered" End If End Sub Am currently using this to ask for a password before allowing people to view the sheet, but would prefer to use a usrform, i know how to creat and asign the form, but am not sure of the exact text as fairly new to userforms, Prefer to have password char as ******** when typed and have been told this is not possible with input box. Any help -- Message posted via http://www.officekb.com |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Password Userform help !!!!
Check your other post.
K1KKKA wrote: Sub Sunselect() Dim PassStr As String PassStr = InputBox("Enter Password Please", "My Password Prompt") If PassStr = "Manager" Then Sheets("Sun").Select Range("A11").Select Else MsgBox "Wrong Password Entered" End If End Sub Am currently using this to ask for a password before allowing people to view the sheet, but would prefer to use a usrform, i know how to creat and asign the form, but am not sure of the exact text as fairly new to userforms, Prefer to have password char as ******** when typed and have been told this is not possible with input box. Any help -- Dave Peterson |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Password Userform help !!!!
If using a userform to prompt for a password, you'll need a textbox for the
user to enter the password. On the properties, set the PasswordChar to a * You'll also need a couple of buttons. OK and Cancel probably. The code for the OK button could be something like:- Private Sub CommandButton1_Click() PassStr = TextBox1.Value If PassStr = "Manager" Then Sheets("Sun").Select Range("A11").Select Else MsgBox "Wrong Password Entered" TextBox1.Value = "" 'Removes previously entered password End If End Sub "K1KKKA" wrote: Sub Sunselect() Dim PassStr As String PassStr = InputBox("Enter Password Please", "My Password Prompt") If PassStr = "Manager" Then Sheets("Sun").Select Range("A11").Select Else MsgBox "Wrong Password Entered" End If End Sub Am currently using this to ask for a password before allowing people to view the sheet, but would prefer to use a usrform, i know how to creat and asign the form, but am not sure of the exact text as fairly new to userforms, Prefer to have password char as ******** when typed and have been told this is not possible with input box. Any help |
#5
Posted to microsoft.public.excel.misc
|
|||
|
|||
Password Userform help !!!!
On Jan 10, 2:51 pm, "John Cleese via OfficeKB.com" <u5428@uwe wrote: I've had managed to use the following code within a userform textbox change function, that will read characters as they are typed into the textbox and add them to a temporary password variable 'tmpPWord', then replace the typed character with a * for display in the textbox. Therefore, the user will only see a row of *'s in the textbox, yet the actual password is stored in temporary variable 'tmpPWord'. Try it out! I hope it works for you. Private Sub TextBoxPassword_Change() Dim repeatCancel As Boolean Dim i As Integer Dim tmpTextBoxText As String tempWord = "" If Len(TextBoxPassword.Value) < Len(dispPassWord) Then dispPassWord = Left(dispPassWord, Len(dispPassWord) - 1) tmpPWord = Left(pWord, Len(tmpPWord) - 1) Else If Right(TextBoxPassword.Value, 1) < "*" Then If Len(TextBoxPassword.Value) 1 Then tempWord = Right(TextBoxPassword.Value, 1) dispPassWord = dispPassWord & "*" Else tempWord = TextBoxPassword.Value dispPassWord = "*" End If tmpPWord = tmpPWord & tempWord TextBoxPassword.Value = dispPassWord End If End If End Sub Regards John Cleese K1KKKA wrote: Sub Sunselect() Dim PassStr As String PassStr = InputBox("Enter Password Please", "My Password Prompt") If PassStr = "Manager" Then Sheets("Sun").Select Range("A11").Select Else MsgBox "Wrong Password Entered" End If End Sub Am currently using this to ask for a password before allowing people to view the sheet, but would prefer to use a usrform, i know how to creat and asign the form, but am not sure of the exact text as fairly new to userforms, Prefer to have password char as ******** when typed and have been told this is not possible with input box. Any help-- Message posted viahttp://www.officekb.com- Hide quoted text -- Show quoted text - Many thanks works for me |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
develop a macro which takes password protection on and off | Excel Discussion (Misc queries) | |||
Error when save as CSV with VBA password protection on | Excel Discussion (Misc queries) | |||
Protect Workbook vs Worksheet?? | Excel Worksheet Functions | |||
Password Issue | Excel Discussion (Misc queries) | |||
Password cannot be removed | Excel Discussion (Misc queries) |