Internet Explorer - log in to a webpage

kacper887

New Member
Joined
Feb 12, 2018
Messages
6
Hello,

I try to write a macro for:

1) Opening a certain webpage in Interner Explorer 11 (I am using 64-Bit MS Excel 2016)
2) Going to specific fields within a website
3) Providing "User ID" and "Password" values
4) Clicking "Login" button

I am a VBA beginner :) Thank you in advnce for any help!

Below I provide my current code, which gets stuck on:
Do Until Not ie.Busy And ie.readyState = 4 (I've got to put "xxx" in terms of company data protection):


Sub Open_Login()

Set ie = CreateObject("InternetExplorer.Application")
my_url = "xxx"
With ie
.Visible = True
.navigate my_url
.Top = 50
.Left = 530
.Height = 400
.Width = 400

Do Until Not ie.Busy And ie.readyState = 4
DoEvents
Loop

End With

ie.document.getElementById("xxx").Value = "xxx"
ie.document.getElementById("xxx").Value = "xxx"

ie.document.getElementById("xxx").Click
Do Until Not ie.Busy And ie.readyState = 4
DoEvents
Loop

End Sub


I've also found sth like this in the web, but did not test it yet:


Sub Open_Login()

Set ie = CreateObject("InternetExplorer.application")
ie.Visible = True
ie.navigate ("xxx" & ActiveCell)

Do
If ie.readyState = 4 Then
ie.Visible = True
Exit Do
Else
DoEvents
End If
Loop

ie.document.forms(0).all("xxx").Value = "xxx"
ie.document.forms(0).all("xxx").Value = "xxx"
ie.document.forms(0).submit

End Sub
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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