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


michelxld Wrote:
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


Hi Michel, no have dubt YOU ARE A WIZARD AND TKS FOR PATIENCE...
....

The macro work fine

Only one...

For me not is important to import for each page the data into a
different sheet... Page A into sheet A, page B into sheet B ecc.....
Important is to insert all records only in one sheet for example into
a sheet named TABELLA.
Not is important to import also the title of record is the same for
each page.
Start the import of record from A2..
Is possible this modify?
Tks and "kiss" from Napoli


--
sal21


------------------------------------------------------------------------
sal21's Profile: http://www.excelforum.com/member.php...fo&userid=2040
View this thread: http://www.excelforum.com/showthread...hreadid=377874