PDA

View Full Version : Website Auto Login - Type as Hidden - VBA



exc
07-10-2018, 07:22 AM
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:




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:


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



Password:


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:


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:


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.