我无法点击页面中的链接,因为在每个搜索框中输入一个数字后链接会不断变化。我尝试了几个VBA代码,但无法实现它。
<A href="../finding/data?data=ALL&version=0&edocid=0&ssid=05BDPUSPHL&refnum=15Q100595&defaultemail=abc@abc.com&snpid=15834667918&servicecd=E" target=_blank>Data</A>
&#13;
Sub try()
Dim ie As Object
Dim MyHTML_Element As IHTMLElement
Dim MyURL As String
Dim MyURLSer As String
Set ie = CreateObject("InternetExplorer.Application")
On Error GoTo Err_Clear
MyURL = "[http://test.com/login][1]"
Set MyBrowser = New InternetExplorer
MyBrowser.Silent = True
MyBrowser.navigate MyURL
MyBrowser.Visible = True
Do
Loop Until MyBrowser.readyState = READYSTATE_COMPLETE
Set HTMLDoc = MyBrowser.document
HTMLDoc.all.j_username.Value = "User" 'Enter your email id here
HTMLDoc.all.j_password.Value = Password'Enter your password here
For Each MyHTML_Element In HTMLDoc.getElementsByTagName("input")
If MyHTML_Element.Type = "button" Then MyHTML_Element.Click: Exit For
Next
On Error GoTo Err_Clear
MyURL = "http://test.com/home"
Set MyBrowser = New InternetExplorer
MyBrowser.Silent = True
MyBrowser.navigate MyURL
MyBrowser.Visible = True
Do
Loop Until MyBrowser.readyState = READYSTATE_COMPLETE
Set HTMLDoc = MyBrowser.document
HTMLDoc.all.searchKeyword.Value = "223645" 'Enter your email id here
Call HTMLDoc.parentWindow.execScript("submitSearch();", "javascript")
For Each l In ie.document.getElementsByTagName("a")
If l.className = "docCheckBox" Then l.Click: Exit For
Next
Err_Clear:
If Err <> 0 Then
Err.Clear
Resume Next
End If
End Sub