简体   繁体   English

使用 excel 宏单击下一步按钮

[英]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'.我正在尝试让宏在 Internet Explorer 中打开一个页面,输入登录信息,单击登录,然后在下一页上,单击“我同意”。 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") Next ele Do While IE.Busy Application.Wait DateAdd("s", 1, Now) 循环设置 eles = idoc.getElementsByTagName("input")

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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