简体   繁体   中英

clicking next button with excel macro

I am trying to get the macro to open up a page in internet explorer, enter login information, click login, then on the next page, click 'I agree'. Here is what I have so far.

  Sub Test1()
   
       Dim IE As Object
       Set IE = CreateObject("InternetExplorer.Application")
       
       IE.Visible = True
       IE.navigate "website.com"
       
       Do While IE.Busy
           Application.Wait DateAdd("s", 1, Now)
       Loop
       
       Dim idoc As MSHTML.HTMLDocument
       Set idoc = IE.document
       
       idoc.all.orgCode.Value = "****"
       idoc.all.UserName.Value = "****"
       idoc.all.Password.Value = "****"
       
        Dim ele As MSHTML.IHTMLElement
       
       Dim eles As MSHTML.IHTMLElementCollection
       Set eles = idoc.getElementsByTagName("input")
       
       For Each ele In eles
           If ele.Value = "Login" Then
               ele.Click
           Else
           End If
           Next ele
   End Sub

This is enough to get me to the page where I need to click 'I agree', but I am unsure of how to get it to click the 'I agree' button.

Here is what comes up under inspect element

在此处输入图像描述

Can anyone help me with what to do next?

Next ele Do While IE.Busy Application.Wait DateAdd("s", 1, Now) Loop Set eles = idoc.getElementsByTagName("input")

    For Each ele In eles
    If ele.Value = "I Agree" Then
        ele.Click
    Else
    End If
    

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM