How to click on a hyperlink (aspx page) and save
The hyperlink i'm trying to click using VBA looks like:
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 I already got the VBA code to take a numerical value from cell A1 from excel sheet 1 to prefill a search box, click the search button, and list several hyperlinks. I need the 2nd part of the code to click on a particular hyperlink titled "OH - House Bill of Lading" (above). I don't know if its because this is an aspx page but i've tried googling and using other codes but to no avail.
The code i have so far is:
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 SubI tried doing it as 2 separate macros hence the call uppercase. Any suggestions?
链接地址: http://www.djcxy.com/p/38006.html上一篇: 如何使用快递创建和阅读会话
下一篇: 如何点击一个超链接(aspx页面)并保存
