0
votes

I have a webpage on which i want to autologin and click on submit button using vba the code is below

'start a new subroutine called SearchBot
Sub SearchBot()

    'dimension (declare or set aside memory for) our variables
    Dim objIE As InternetExplorer 'special object variable representing the IE browser
    Dim aEle As HTMLLinkElement 'special object variable for an <a> (link) element
    Dim y As Integer 'integer variable we'll use as a counter
    Dim result As String 'string variable that will hold our result link

    'initiating a new instance of Internet Explorer and asigning it to objIE
    Set objIE = New InternetExplorer

    'make IE browser visible (False would allow IE to run in the background)
    objIE.Visible = True

    'navigate IE to this web page (a pretty neat search engine really)
    objIE.navigate "mywebpage"

    'wait here a few seconds while the browser is busy
    Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop

    'in the search box put cell "A2" value, the word "in" and cell "C1" value
    objIE.document.getElementById("loginID").Value = ("userid")
    objIE.document.getElementById("password").Value = ("password")

after this code i want to click on submit button using vba

HTML inspect element code is below

<INPUT class=btn2 type=submit value=Submit name=submit1>
1
<INPUT class=btn2 type=submit value=Submit name=submit1>MoRizwan

1 Answers

1
votes

Try finding element by name and click it.

objIE.document.getElementsByName("submit1")(0).click