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.
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,622
Messages
6,120,572
Members
448,972
Latest member
Shantanu2024

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