VBA: Working with Loops To Log into Website

souf12

New Member
Joined
Aug 20, 2020
Messages
4
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I'm having a hard time getting my vba code to work. What my code is doing is opening a website, entering the username and password and then I want it to click the login button. My current problem however is that I cannot get my code's loop to Click the Login button once my username and password is inputted.

Any ideas on where I'm going wrong?

Sub Basic_Web_Query() Dim ieApp As InternetExplorer Dim ieDoc As Object Dim ieTable As Object Dim clip As DataObject 'create a new instance of ie Set ieApp = New InternetExplorer 'you don’t need this, but it’s good for debugging ieApp.Visible = True 'assume we’re not logged in and just go directly to the login page ieApp.Navigate "https://app.xx.com/login" Do While ieApp.Busy: DoEvents: Loop Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop Set ieDoc = ieApp.Document 'fill in the login form – View Source from your browser to get the control names With ieDoc.forms(0) .Document.all.Item("email").Value = "xx" .Document.all.Item("password").Value = "yy" End With Dim loginButton As Object Set loginButton = ieApp.Document.getElementsByClassName("btn btn-primary-lg")(0) loginButton.Click While ieApp.Busy Or ieApp.ReadyState <> 4: DoEvents End Sub
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,214,527
Messages
6,120,058
Members
448,940
Latest member
mdusw

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