使用VBA登录网站后如何单击链接

时间:2019-08-22 18:05:00

标签: excel vba

登录到网站后,我想单击链接,但登录后并没有移动任何地方,我编码了许多鳕鱼,但是没有一个在工作,请对此提供帮助

'''

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 = "example.in"
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.UserName.Value = "xyz"
HTMLDoc.all.Password.Value = "****"

For Each oHTML_Element In HTMLDoc.getElementsByTagName("input")
If oHTML_Element.Type = "testdrive.aspx" 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
'''

0 个答案:

没有答案