Thread: import from web
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
michelxld[_6_] michelxld[_6_] is offline
external usenet poster
 
Posts: 1
Default import from web


Hello Sal21 , Hello Leith

I don't think that is the best way but you may try this macro to import
tables from all Web Pages

test With Excel2002 & WinXP, 4 minutes to run the 26 WebPages



Sub Importer_tableauPageWeb()
'MichelXld le 09.06.2005
'
'activate Microsoft HTML Objects Library
'activate Microsoft Internet Controls
'
Dim IE As InternetExplorer
Dim maPageHtml As HTMLDocument
Dim Htable As IHTMLElementCollection
Dim maTable As IHTMLTable
Dim j As Integer, i As Integer, x As Integer, Ligne As Integer
Dim NbPages As Byte

Application.ScreenUpdating = False

For NbPages = 65 To 90
Ligne = 0
Sheets.Add After:=Worksheets(Worksheets.Count)
ActiveSheet.Name = Chr(NbPages)

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = False
IE.navigate "http://www.capitalmarket.com/bulletin/bsebhav.asp?var=" &
Chr(NbPages)
Do Until IE.readyState = READYSTATE_COMPLETE
DoEvents
Loop

Set maPageHtml = IE.document
Set Htable = maPageHtml.getElementsByTagName("table") 'objet type
table

For x = 2 To Htable.Length - 1
Ligne = Ligne + i + 1

Set maTable = Htable(x)

For i = 1 To maTable.Rows.Length 'each row in table

For j = 1 To maTable.Rows(i - 1).Cells.Length 'each cell in row
Cells(Ligne + i, j) = maTable.Rows(i - 1).Cells(j - 1).innerText
Next j

Next i
Next x

DoEvents
Set IE = Nothing
Next NbPages

Application.ScreenUpdating = True
End Sub



Regards ,
michel


--
michelxld
------------------------------------------------------------------------
michelxld's Profile: http://www.excelforum.com/member.php...o&userid=17367
View this thread: http://www.excelforum.com/showthread...hreadid=377874