Hi All,
I am trying to retreive share prices from the following page http://www.asx.com.au/asx/markets/pr...Codes&asxCodes= AMP
I can navigate several pages and searches to get there but I can't seem to get the specific piece of data I want to extract. I want to extract the last share price, the html code for this is as follows:
<tdclass="last">4.270 </td>
Here is the vb script that is causing me problems (and the Dim settings for the entire script, I have not inculded the entire script as the other parts are working fine), I have tried it a couple of ways:
Dim clip As DataObject
Dim Element As Object
Dim btnInput As Object ' MSHTML.HTMLInputElement
Dim ElementCol As Object ' MSHTML.IHTMLElementCollection
Dim Link As Object ' MSHTML.HTMLAnchorElement
Dim ieTable As Variant
Dim strCountBody As String
Dim lStartPos As Long
Dim lEndPos As Long
Dim TextIWant As String
Dim i As Long
Dim ie As Object
Option 1:
With .Document.Forms(2)
For i = 0 To .getElementsByTagName("td").Length - 1
Set ieTable = .getElementsByTagName("td").Item(i)
TextIWant = ieTable.getAttribute("innerText")
If TextIWant <> "" Then
If InStr(1, TextIWant, "last") > 0 Then
Range("C" & ActiveCell.Row).Value = TextIWant
Exit For
End If
End If
Next
Option 2:
With .Document.Forms(2)
Set ieTable = .All.Item("last")
Set clip = New DataObject
clip.SetText "<html>" & ieTable.outerHTML & "</html>"
clip.PutInClipboard
Range("C" & ActiveCell.Row).Select
Range("C" & ActiveCell.Row).PasteSpecial
Thanks, your help would be much appreciated. I'm sure I have made some rookie error as I have done lots of website navigation via excel (and form filling), but never retrieval.
Cheers
I am trying to retreive share prices from the following page http://www.asx.com.au/asx/markets/pr...Codes&asxCodes= AMP
I can navigate several pages and searches to get there but I can't seem to get the specific piece of data I want to extract. I want to extract the last share price, the html code for this is as follows:
<tdclass="last">4.270 </td>
Here is the vb script that is causing me problems (and the Dim settings for the entire script, I have not inculded the entire script as the other parts are working fine), I have tried it a couple of ways:
Dim clip As DataObject
Dim Element As Object
Dim btnInput As Object ' MSHTML.HTMLInputElement
Dim ElementCol As Object ' MSHTML.IHTMLElementCollection
Dim Link As Object ' MSHTML.HTMLAnchorElement
Dim ieTable As Variant
Dim strCountBody As String
Dim lStartPos As Long
Dim lEndPos As Long
Dim TextIWant As String
Dim i As Long
Dim ie As Object
Option 1:
With .Document.Forms(2)
For i = 0 To .getElementsByTagName("td").Length - 1
Set ieTable = .getElementsByTagName("td").Item(i)
TextIWant = ieTable.getAttribute("innerText")
If TextIWant <> "" Then
If InStr(1, TextIWant, "last") > 0 Then
Range("C" & ActiveCell.Row).Value = TextIWant
Exit For
End If
End If
Next
Option 2:
With .Document.Forms(2)
Set ieTable = .All.Item("last")
Set clip = New DataObject
clip.SetText "<html>" & ieTable.outerHTML & "</html>"
clip.PutInClipboard
Range("C" & ActiveCell.Row).Select
Range("C" & ActiveCell.Row).PasteSpecial
Thanks, your help would be much appreciated. I'm sure I have made some rookie error as I have done lots of website navigation via excel (and form filling), but never retrieval.
Cheers