PDA

View Full Version : Click Login button using VBA



kolturra
05-25-2020, 08:45 PM
Hi,

Hope everyone is doing fine. I am trying to upload my resume everyday with help of macro.

Would request to help me with code for HTML code. I am trying to click login buttion using VBA.



HMTL CODE


<div class="action row mb0">
<div class="col s12">
<div class="g-recaptcha" data-sitekey="6Lfr8SEUAAAAACgWL1C--Pup9o8uBElCNXYZ4vfL" data-callback="loginRecaptchaCallback" data-size="invisible"></div><button class="waves-effect waves-light btn-large btn-block btn-bold blue-btn textTransform" type="submit" data-ga-track="spa-event|login|login|Save">Login</button>


So For My VBA CODE


Dim htmldoc As HTMLDocument
Dim mybrowser As InternetExplorer
Sub connecttoO1C()
Dim IE As Object
Dim myhtml_element As IHTMLElementCollection
Dim htmlInput As MSHTML.HTMLInputElement
Dim htmlInput1 As Object
Dim elemCollection As Object
Dim htmlcoll As MSHTML.IHTMLElementCollection
Dim frm As Object
Dim objElement As Object
Dim objCollection As Object
Dim i As Long
Dim i1 As Long
Dim User_ID As String
Dim Password_ID As String
Dim a As String
Dim x As Workbook
Dim links, link
Application.EnableEvents = True
Set x = ThisWorkbook
User_ID = "XXXXXXXXXXXXX"
Password_ID = "XXXXXXXX"
If User_ID = "" Then
MsgBox ("Untill you type the NAUKRI username, macro will not run futher")
On Error GoTo username
Exit Sub
ElseIf Password_ID = "" Then
MsgBox ("Untill you type the NAUKRI password, macro will not run futher")
On Error GoTo passwordid
Exit Sub
Else
Set IE = CreateObject("InternetExplorer.application")
IE.navigate "https://www.naukri.com/nlogin/login?msg=0&URL=https%3A%2F%2Fmy.naukri.com"
IE.Visible = True
Do
Loop Until IE.readyState = READYSTATE_COMPLETE: DoEvents
Application.Wait (Now + TimeValue("0:00:00"))
IE.document.getElementById("usernameField").Value = User_ID
IE.document.getElementById("passwordField").Value = Password_ID


'I AM STRUCK HERE

IE.document.getElementByTagName("Login").Click
'- DON'T KNOW WHAT CODE SHOULD I WRITE
End Sub




Thanks,
Rao