使用VBA

时间:2016-12-19 00:18:13

标签: html vba button

我在点击此按钮时遇到问题:

enter image description here

我正在尝试申请:

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

2 个答案:

答案 0 :(得分:0)

objIE.Document.getElementById("a123").getElementsByTagName("button")(0).click

答案 1 :(得分:0)

这样的事情应该为你完成。

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