View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel[_189_] joel[_189_] is offline
external usenet poster
 
Posts: 1
Default Web Query, not capturing data


The data on the page is in a frame which the webpage gets from a second
URL. the code below goes to the 2nd URL and puts the data on Sheet1.


Sub greenfutures()

URL = "http://nymex.greenfutures.com/markets/rj-csf.html"

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True


'get web page
IE.Navigate2 URL
Do While IE.readystate < 4 Or _
IE.busy = True
DoEvents
Loop

Set IFrame = IE.document.getelementsbytagname("IFRAME")

src = IFrame.Item(0).src


'get web page
IE.Navigate2 src
Do While IE.readystate < 4 Or _
IE.busy = True
DoEvents
Loop

'wait until all the data is returned.
Do
Set Table = IE.document.getelementsbytagname("Table")
Set Data = Table(1)
Loop While Data Is Nothing

With Sheets("sheet1")
RowCount = 1
For Each IRow In Data.Rows
ColCount = 1
For Each cell In IRow.Cells
.Cells(RowCount, ColCount) = cell.innertext
ColCount = ColCount + 1
Next cell
RowCount = RowCount + 1
Next IRow
End With

IE.Quit
End Sub


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=151687

Microsoft Office Help