(Solved) – VBA to click on a button on an IE form to submit it

  • by
(solved)-–-vba-to-click-on-a-button-on-an-ie-form-to-submit-it

I’m quite new to VBA so please bear with me. I’ve been trying to create an automation to fill in username and password and login to a site (to start with) but I’ve been having trouble trying to click on the submit button. Scoured the internet and learnt a whole bunch of things but I didnt find anything that seems to work. The page loads and fills in the details and nothing happens when I run the code below.

Would greatly appreciate some help with this. Thanks in advance as always!

Sub worldcheck()

Dim lastrow As Long
Dim IE As Object
Dim cel As Range
Dim post As Object
Dim ws As Worksheet
Dim element As Object

Set ws = Sheets("sheet1")
Set IE = CreateObject("internetexplorer.application")
lastrow = ws.Range("B" & ws.Rows.Count).End(xlUp).Row

IE.Visible = True
IE.Navigate "https://www.world-check.com/frontend/login/"

Do While IE.busy
    DoEvents
Loop

Application.Wait (Now   TimeValue("0:00:2"))

IE.document.getElementbyID("username").Value = ws.Range("D2")
IE.document.getElementbyID("password").Value = ws.Range("D3")
IE.document.getElementbyClass("button").click

Do While IE.busy
    DoEvents
Loop

End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *