using VBA to enter website login information

uwsp427

New Member
Joined
Aug 21, 2013
Messages
5
I am trying to automate the login to a website that I use regularly. I have written code that will succesfully:

1. Open the website
2. Enter the correct username
3. Enter the correct password

Whenever the code attempts to .submit the information I get a website error that states my username/password information is incorrect. However, when I deactivate the .submit and manually click "submit" with my mouse it logs into the website. One thing that I have noticed is that when I manually click "submit" the username changes from "MyUserName" to "********", but when the VBA code executes the .submit it does not make this adjustment. I am using Excel 2007 on a Windows 7 32 bit operating system. Here is the code:


Sub OpenSite()

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 "Website"
Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop

Set ieDoc = ieApp.Document

With ieDoc.forms(0)
.UserId.Value = "Username"
.PIN.Value = "Password"
.submit
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Can you post the URL?

Without that it's pretty hard to help with this sort of thing.
 
Upvote 0
There is something flakey about the fidelity login page. I found that you have to enter the username twice, once into the "ssn" field, and once into the "ssn-visible" field. i.e.

iedoc.getElementsByTagName("ssn").item(0).value = "xxxxxxxxx"
iedoc.getElementsByTagName("ssn-visible").item(0).value = "xxxxxxxxx"
iedoc.getElementsByTagName("pin") .item(0).value= "yyyyyyy"
iedoc.getElementsByTagName("BUTTON").item(0).click
 
Upvote 0
Thanks!!!!

This was dead in the water a few months ago for me and I moved on to some other means of getting the information I needed. But the solution was as simple as just changing the forms that the information was sent to. I was able to get your code to work and then I was able to also cut out the duplicative use of usernames. Here is the working code:

Sub GetTable()

'set variable types
Dim ieApp As InternetExplorer
Dim ieDoc As Object
Dim ieTable As Object
Dim clip As DataObject

'create a new instance of internet explorer
Set ieApp = New InternetExplorer

'comment this section out if you don't need to open the browser;however, its useful for debugging
ieApp.Visible = True

'assume we’re not logged in and just go directly to the login page
ieApp.Navigate "https://login.fidelity.com/ftgw/Fas...x.fidelity.com/ftgw/fbc/ofsummary/defaultPage"
Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop

Set ieDoc = ieApp.Document

'fill in the login form

With ieDoc.forms(0)
.ssn.Value = "EnterYourUserName"
.PIN.Value = "EnterYourPassword"

End With
With ieDoc.forms(0)
.submit
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,532
Messages
6,114,177
Members
448,554
Latest member
Gleisner2

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