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

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Forum statistics

Threads
1,215,264
Messages
6,123,960
Members
449,135
Latest member
jcschafer209

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