Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GET ITEM in dropdown in web page... 1

Status
Not open for further replies.

sal21

Programmer
Apr 26, 2004
428
IT
Code:
 Sub LIST_DROPDOWN()

    Const URL As String = "[URL unfurl="true"]http://anagrafe.cng.it/anagrafe/geometri.aspx"[/URL]
    Dim IE As New InternetExplorer, oHtml As HTMLDocument, post As Object, R&

    With IE
        .Visible = True
        .Navigate URL
        Do While .Busy: DoEvents: Loop
        While .Busy Or .ReadyState < 4: DoEvents: Wend
        Set oHtml = .Document
    End With

    'Application.Wait Now + TimeValue("00:00:02")

    For Each post In oHtml.getElementsByClassName("dxeListBoxItemRow")
        With post.getElementsByTagName("td")
            Debug.Print .Item(0).innerText
        End With
    Next post
    
End Sub

the code get twice the item in dropdown!!!!
 
Well, yes - because there are two tables with the data in them.

Several ways of fixing this. Here's one:

Code:
    Const URL As String = "[URL unfurl="true"]http://anagrafe.cng.it/anagrafe/geometri.aspx"[/URL]
    Dim IE As New InternetExplorer, oHtml As HTMLDocument, post As Object, R&

    With IE
        .Visible = True
        .Navigate URL
        Do While .Busy: DoEvents: Loop
        While .Busy Or .ReadyState < 4: DoEvents: Wend
        Set oHtml = .Document
    End With

    [COLOR=green]'Application.Wait Now + TimeValue("00:00:02")[/color]

    For Each post In oHtml.getElementById("ctl00_ContentPlaceHolder1_ddlCodiceCollegio_DDD_L_D").getElementsByTagName("td")
        Debug.Print post.innerText
    Next
 
strongm, this way is the best!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top