我试图使用VBA点击的超链接如下所示:
a id=SearchResults_dgResults__ctl5_lnkbtnGetImage
class=ItemStyle style="FONT-SIZE: 10pt; FONT-FAMILY: Arial" href="javascript:__doPostBack
('SearchResults$dgResults$_ctl5$lnkbtnGetImage','')">OH - House Bill of Lading /a
我已经获得了VBA代码,从excel工作表1的单元格A1中取一个数值,预填充一个搜索框,单击搜索按钮,并列出几个超链接 . 我需要代码的第二部分来点击 Headers 为“OH - House提单”的特定超链接(上图) . 我不知道它是否因为这是一个aspx页面,但我尝试使用谷歌搜索和使用其他代码但无济于事 .
我到目前为止的代码是:
Public Sub IE_Search_and_Extract()
Dim URL As String
Dim IE As SHDocVw.InternetExplorer
Dim htmlInput As MSHTML.HTMLInputElement
Dim htmlColl As MSHTML.IHTMLElementCollection
Dim HTMLdoc As HTMLDocument
URL = "http://eglsiis12c.egl.corp/docvisionsearch/DocVisionSearch.aspx"
Set IE = Get_IE_Window(URL)
If IE Is Nothing Then
Set IE = New SHDocVw.InternetExplorer
End If
With IE
SetForegroundWindow .hwnd
.Navigate URL
.Visible = True
While .Busy Or .ReadyState READYSTATE_COMPLETE
DoEvents
Wend
.Document.getElementById("House1_txtHouseBillNum").Value = ActiveSheet.Cells(1, 1)
.Document.getElementById("House1:btnHouseSearch").Click
While .Busy Or .ReadyState READYSTATE_COMPLETE
DoEvents
Wend
End With
Call Uppercase
End Sub
Sub Uppercase()
Dim IE As SHDocVw.InternetExplorer
Set IE = IE.Document.getElementsByTagName("a")
For Each IE In IE.Document.getElementsByTagName("a")
If InStr(IE.innerText, "OH - Bill Lading of Lading") > 0 Then IE.Click
Next
End Sub
我尝试将其作为2个独立的宏,因此调用大写 . 有什么建议?