PDA

Click to See Complete Forum and Search --> : [RESOLVED] Ho to use READYSTATE_COMPLETE in same session...


luca90
May 22nd, 2006, 07:18 AM
I have this code. I have insert the READYSTATE_COMPLETE but the macro not attendig this event why?
In effect after the click event the web show a new table in same page, and i would want to attending the page is completly free to get data... (see the comment in code after event click)

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, LINEA2 As Integer
Dim Y As Byte
Dim INP As Object

'Application.ScreenUpdating = False

LINEA = Sheets("FOGLIO3").Cells(65536, 1).End(xlUp).Row

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.navigate "http://antfat/antfat/ewaf/elencoSbilanci;jsessionid=wQWxQZWblaHUcAaeuCzp2T7"

Do Until IE.readyState = READYSTATE_COMPLETE
DoEvents
Loop

Set maPageHtml = IE.document

AVANTI:

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

For X = 2 To Htable.Length - 1
Y = 2
Set maTable = Htable(X)

For I = Y To maTable.Rows.Length

LINEA = LINEA + 1

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

Next J

If LINEA = 101 + LINEA2 Then
Set INP = IE.document.all.Item("PAGINA_AVANTI")
INP.Click

''''''''''''''''''''''''''
Do Until IE.readyState = READYSTATE_COMPLETE
DoEvents
Loop
''''''''''''''''''''''''''
LINEA2 = LINEA - 1
GoTo AVANTI
End If

Next I

Next X

ActiveWorkbook.Save

DoEvents
IE.Quit
Set IE = Nothing

'Application.ScreenUpdating = True

End Sub