0

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> Commented Dec 1, 2017 at 10:26

1 Answer 1

1

Try finding element by name and click it.

objIE.document.getElementsByName("submit1")(0).click
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks J.B. it works , it is the same way to click on below code like <A class=level1 href="/pretups/scheduledReportAction.do?method=loadFirst&amp;module=C2S&amp;moduleCode=DWNLDRPT">Download reports</A>
Hello @J.B. can you please provide solution from your side.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.