Inputbox Password

tobeon

Board Regular
Joined
Jan 26, 2003
Messages
81
how can i make an input box display *s when you type in it (so it can be used for passwords)

InputBox("Please Enter New Password")

thank you
 
Daniel's code works great!
http://www.danielklann.com/excel/hiding_text_in_a_vba_inputbox.htm



I don't really know how it workds, but the input box works perfectly. I use
InputBoxDK() to get a password from users. I then use this passord to log into a website. The problem I'm having is that if the website is already open, the sequence of sendkeys I'm using doesn't seem to line up correctly and the password shows up in the address bar of the website!

Is it possible to have the password show up to the website ****, else recognize if the passord is not being sent where it should be?

This is the code I'm using to log into the website:

Code:
Sub SaphireLogIn(Optional ByVal dCloseTime As Date = 0)
        Dim IE As Object, PW As String, sUserName As String
        PW = InputBoxDK("Enter Your Password Please." & Chr(10) & Chr(10) & "Make sure all Sapphire windows are CLOSED, otherwise your password may show up on the screen for a few seconds!", "Password Please")
        sUserName = Worksheets("Saphire").Range("K1").Value
        Set IE = CreateObject("InternetExplorer.Application")
        IE.Visible = True
        IE.Navigate "https://k12.mtwp.net/Gradebook/ClassSelect.cfm"
'       Check for good connection to web page loop!
        Do
                If IE.ReadyState = 4 Then
                    Exit Do
                    Else
                            DoEvents
                End If
        Loop

'       Wait for window to open!
        Application.Wait (Now + TimeValue("0:00:02"))

'       Send logg-on information!
'       May need additional SendKeys as needed?
'       Determine by the actual key-stroks needed!
        SendKeys sUserName, True
        SendKeys "{TAB}", True                                 ' Log On
        SendKeys PW, True
        SendKeys "{ENTER}", True
End Sub
 
Upvote 0

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Hi ,

I tried your code and it worked fine on my PC. The Password Characters are sent to the Password Entry Field as intended.

The use of SendKeys is not very reliable..I wonder whether you could use Automation to reference the Password TextBox on the Web Page instead of sending Key Strokes.

Unfortunatly, I am not familiar with the IE Object Library but I guess theorically, this can be done.

Regards.
 
Upvote 0
Hi again,

I 've done some research to see if I could come up with something and the following may prove interesting...Try it and see if it works for you :


Add a Class Module to your Project and accept the Default name Class1

Add this Code to Class1 :

Code:
Public WithEvents IE_Events As InternetExplorer

Private Sub IE_Events_DocumentComplete(ByVal pDisp As Object, URL As Variant)

Dim inp As Object

'\\ Let's go to DocumentComplete event
If (pDisp Is IE) Then
    '\\ Url could change so take care of it
    If InStr(1, URL, "https://k12.mtwp.net/Gradebook/ClassSelect", vbTextCompare) Then
    
    With IE.document.all
            Set inp = .Item("j_username")
            inp.Value = sUserName  'Your ID
            
            Set inp = .Item("j_password")
            inp.Value = PW  'Your Password
            
            Set inp = .Item("login") ' Press Log In
            inp.Click
     End With
            
     End If
End If

End Sub


Next, add this to a Standard Module :( It is actually your Code with some modifications)

Code:
Dim objClass1 As Class1
'\\ Declare the Variables as Global so they can be seen by the Class Module
Public IE As Object, PW As String, sUserName As String

Sub SaphireLogIn()

        sUserName = "Your ID"
        PW = InputBoxDK("Enter Your Password Please." & Chr(10) & Chr(10) & "Make sure all Sapphire windows are CLOSED, otherwise your password may show up on the screen for a few seconds!", "Password Please")
'        sUserName = Worksheets("Saphire").Range("K1").Value
        Set IE = CreateObject("InternetExplorer.Application")
        
        '\\***************ADD THESE LINES***************************\
        '\\ Instantiate Class1 and Hook the Events                 '\
        Set objClass1 = New Class1                                 '\
        Set objClass1.IE_Events = IE                               '\
        '\\ ********************************************************
        
        
        IE.Visible = True
        IE.navigate "https://k12.mtwp.net/Gradebook/ClassSelect.cfm"
        
End Sub

I found out about the Text Field names (which is a requirement in this scenario for using Automation) by looking at the Page Source Code .

The LogIn is automatically carried out after the Page is loaded thanks to the Event Hook set up in the Class Module...So No need for a loop in you main Procedure.


Regards.
 
Upvote 0
Thank you for taking the time to research this Rafaaj. I looked at the source code for the site, and I think I will be able to pickout the name of the item if it changes in the future. Unfortunately I'm getting an error right now.

I'm getting the following message:
"user-defined type not defined"

at the line:
Public WithEvents IE_Events As InternetExplorer
 
Upvote 0
You need to set a reference to
Microsoft internet controls

How can I do that?

[Edit:] I'm a little slow, I figured it out. Thanks for pointing it out Ivan, and thank you all for your hard work.
 
Upvote 0
I would imagine that by now (i'm using excel 2007) you can get it done without this much code, i'd greatly appreciate if one of you VBA guy's has an easier suggestion, I have very limited capability with VBA so I'm terrified to just paste this much code into my project.

So if you know a better/easier way or you know that it's impossible any other way, i'd greatly appreciated if you take some time to help me.
 
Upvote 0
I would imagine that by now (i'm using excel 2007) you can get it done without this much code (referring to the original code posted by DK), i'd greatly appreciate if one of you VBA guy's has an easier suggestion, I have very limited capability with VBA so I'm terrified to just paste this much code into my project.

So if you know a better/easier way or you know that it's impossible any other way, i'd greatly appreciated if you take some time to help me.
 
Upvote 0
The easiest way has always been to use a userform with a textbox and its password character set as required. If you want to use an Inputbox, you need this sort of code.
 
Upvote 0
how can i make an input box display *s when you type in it (so it can be used for passwords)

InputBox("Please Enter New Password")

thank you

Underneath is a simple piece of code i created when a student clicks on the admin command button and they need to enter a password, if the password entered is correct (Sandown) then enter, else if password wrong then stay in home page.
Private Sub cmdAdmin_Click()
Dim Password
Password = InputBox("Please enter a password to access this location!", "Administrator Security")
If Password = "Sandown" Then
Me.Hide
frmAdmin.Show
Else
MsgBox "Sorry password incorrect, Please try again!"
Me.Hide
frmHome.Show
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,958
Messages
6,175,643
Members
452,663
Latest member
MEMEH

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