【问题标题】:Click an HTML button using VBA使用 VBA 单击 HTML 按钮
【发布时间】:2016-12-19 00:18:13
【问题描述】:

我无法点击此按钮:

我正在申请:

Set The_Input_Elements = objIE.Document.getElementsByTagName("Div")
For Each input_element In The_Input_Elements
    If input_element.getAttribute("id") = "a123" Then
        input_element.Click
        Exit For
    End If

【问题讨论】:

  • 请将 HTML 作为文本发布在您的问题中,而不是图像

标签: html vba button


【解决方案1】:
objIE.Document.getElementById("a123").getElementsByTagName("button")(0).click

【讨论】:

    【解决方案2】:

    这样的事情应该可以为您完成。

    Dim HTMLDoc As HTMLDocument
    Dim oBrowser As InternetExplorer
    Sub Login_2_Website()
    
    Dim oHTML_Element As IHTMLElement
    Dim sURL As String
    
    On Error GoTo Err_Clear
    sURL = "https://www.google.com/accounts/Login"
    Set oBrowser = New InternetExplorer
    oBrowser.Silent = True
    oBrowser.timeout = 60
    oBrowser.navigate sURL
    oBrowser.Visible = True
    
    Do
    ' Wait till the Browser is loaded
    Loop Until oBrowser.readyState = READYSTATE_COMPLETE
    
    Set HTMLDoc = oBrowser.Document
    
    HTMLDoc.all.Email.Value = "sample@vbadud.com"
    HTMLDoc.all.passwd.Value = "*****"
    
    For Each oHTML_Element In HTMLDoc.getElementsByTagName("input")
    If oHTML_Element.Type = "submit" Then oHTML_Element.Click: Exit For
    Next
    
    ' oBrowser.Refresh ' Refresh If Needed
    Err_Clear:
    If Err <> 0 Then
    Debug.Assert Err = 0
    Err.Clear
    Resume Next
    End If
    End Sub
    

    阅读更多 - http://vbadud.blogspot.com/2009/08/how-to-login-to-website-using-vba.html#K9JfScjppte4FvZI.99

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多