PDA

Click to See Complete Forum and Search --> : count record in web page..


luca90
May 19th, 2006, 05:17 AM
i have this hard prob to modify my old macro:
Attached is the macro it work with a cicle For NbPages = 65 To 90 inested this cicle is possible:

first solution for me:
count the record in ie.inner into: Pagine 1 di 4 and click on AVANTI button for 4 click and for ech click get data from table
second soultion for me:
click on AVANTI button do until the sheet is filled with the number of record counted in: "Totale fidi individuati:" in this case 308 reord
other info: each table can contian max 100 record....

attached html and image

Sub Importer_tableauPageWeb_V02()

'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, LINEA As Integer
Dim NbPages As Byte, Y As Byte

Application.ScreenUpdating = False

For NbPages = 65 To 90

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.navigate "http://antfat/antfat/ewaf/elencoSbilanci;jsessionid=TkmfJxApZQ8Z6V4GAjSiStN=" & 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

If X = 2 And NbPages = 65 Then
Y = 1
Else
Y = 2
End If

Set maTable = Htable(X)

For I = Y To maTable.Rows.Length 'rows in table

LINEA = LINEA + 1

For J = 1 To maTable.Rows(I - 1).Cells.Length 'each cell in row
Cells(LINEA, J) = maTable.Rows(I - 1).Cells(J - 1).innerText
Next J

Next I
Next X

DoEvents
IE.Quit
Set IE = Nothing
Next NbPages

Application.ScreenUpdating = True

End Sub