Website Auto Login - Type as Hidden - VBA

excely

New Member
Joined
May 23, 2018
Messages
9
Hi guys,


Im trying to figure out how to have excel login to a particular website via VBA. Currently the code I have works for other websites but this particular site has username/password field types as 'hidden' which I believe is the issue. Here is some of the code I currently have that is working:


Code:
Sub Login ()


Dim ieApp As InternetExplorer
 Dim ieDoc As Object
 Dim ieTable As Object
 Dim clip As DataObject


 Set ieApp = New InternetExplorer
ieApp.Visible = True


 ieApp.Navigate "ANY WEBSITE URL"
 Do While ieApp.Busy: DoEvents: Loop
 Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop


Set ieDoc = ieApp.Document


 With ieDoc.forms(1)
 .UserName.Value = "12345"
 .Password.Value = "ABCD"  
 .submit
 End With


 ieApp.Quit
Set ieApp = Nothing


End Sub


Here is the website inspect element that I am having issues getting the code to work with:


User Name:
Code:
input name="usernameDisplay" style="width: 90px;" onkeypress="return submitenter(event)" type="text" maxlength="50" value=" "
input name="username" type="hidden"


Password:
Code:
input name="password" style="width: 90px;" onkeypress="return submitenter(event)" onfocus="this.select()" type="password" maxlength="50"
input name="login-form-type" type="hidden" value="pwd"


Sign-In Button:
Code:
img id="view:_id10" style="border: currentColor; border-image: none;" src="/images/en/signinbutton.gif"


I have tried changing the username.value and password.value to something like this but still doesn't work:
Code:
ieApp.Document.getElementById ("input type='text' name='usernameDisplay value=' ' ")    
 Application.SendKeys "12345"                  
    ieApp.Document.getElementById("input type='password' name='password'").Click
    Application.SendKeys "ABCD"
          ieApp.Document.getElementById("view:_id10").Click


Any help would be appreciated. Thanks.
 

Some videos you may like

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

excely

New Member
Joined
May 23, 2018
Messages
9
also tried different variations of the code like this which doesnt work either.. the code to click sign in works just cant get the code to input the login/password info
Code:
ieApp.Document.getElementById ("input type='text' name='usernameDisplay value='12345' ")     
        
    ieApp.Document.getElementById("input type='password' name='password'").Value = "ABCD"
          ieApp.Document.getElementById("view:_id10").Click
 

excely

New Member
Joined
May 23, 2018
Messages
9
solved it! for those that are curious:

Code:
For Each inputField In inputFields
        If inputField.getAttribute("name") = "usernameDisplay" Then
            inputField.Value = "12345"
        ElseIf inputField.getAttribute("name") = "password" Then
            inputField.Value = "ABCD"
        End If
    Next inputField
    IE.Document.getElementById("view:_id10").Click
 

Watch MrExcel Video

Forum statistics

Threads
1,123,393
Messages
5,601,403
Members
414,449
Latest member
Pashtun

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
Top