So i have the code that takes a numerical value out of A1 cell from my work sheet. The macro goes to the website, fills in the search form and clicks submit. This works fine, but when you click submit a list of hyperlinks come up and i need a particular one named "OH - House Bill of Lading"
So how would i add that part to the code i already have?
the particular hyperlink i'm trying to click looks like this:
I tried doing this but it gives me an Run-Time error 91 object variable or With Block Variable not set
So how would i add that part to the code i already have?
Rich (BB code):
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
Dim Html As HTMLDocument
Dim Alllinks As Object
Dim HyperLink As Object
Dim objIE As SHDocVw.InternetExplorer
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
End Sub
the particular hyperlink i'm trying to click looks like this:
I tried doing this but it gives me an Run-Time error 91 object variable or With Block Variable not set
Rich (BB code):
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
Dim Html As HTMLDocument
Dim Alllinks As Object
Dim HyperLink As Object
Dim objIE As SHDocVw.InternetExplorer
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
.Document.getElementById ("SearchResults_dgResults__ctl5_lnkbtnGetImage")
.Document.getElementById("OH - House Bill of Lading").Click
End With
End Sub