Simulate click event on a web page

sal21

Active Member
Joined
Apr 1, 2002
Messages
291

CLICK on button on html page​

Based the link:

Link text here

(first, select from listbox AGRIGENTO)

How to click on button >, and go To the next set of records?

Note:
i use the tipical IE object to navigate, from site

...
Code:
Set IE = CreateObject("InternetExplorer.Application")
URL1 = "link text"
IE.Navigate URL1
 
Last edited by a moderator:

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Try this macro. You must set the following references, via Tools -> References, in the VBA editor:

Microsoft HTML Object Library​
Microsoft Internet Controls​

VBA Code:
Public Sub IE_Test()

    Dim IE As InternetExplorer
    Dim HTMLdoc As HTMLDocument
    Dim dropdown As HTMLInputElement
    Dim searchButton As HTMLDivElement
    Dim nextPage As HTMLTableCell
    #If VBA7 Then
        Dim changeEvent As DOMEvent
    #Else
        Dim changeEvent As Object
    #End If
   
    Set IE = New InternetExplorer
    With IE
        .navigate "http://some link"
        While IE.Busy Or IE.readyState <> READYSTATE_COMPLETE: DoEvents: Wend
        .Visible = True
        Set HTMLdoc = .document
    End With
   
    Set changeEvent = HTMLdoc.createEvent("HTMLEvents")
    changeEvent.initEvent "change", True, False

    Set dropdown = HTMLdoc.getElementById("ctl00_ContentPlaceHolder1_ddlCodiceCollegio_I")
    dropdown.Value = "AGRIGENTO"
    dropdown.dispatchEvent changeEvent
   
    Set searchButton = HTMLdoc.getElementById("ctl00_ContentPlaceHolder1_btnFiltra_CD")
    searchButton.Click
   
    While IE.Busy Or IE.readyState <> READYSTATE_COMPLETE: DoEvents: Wend
       
    Set nextPage = HTMLdoc.getElementsByClassName("dxpButton")(1)
    nextPage.Click
   
End Sub
 
Last edited by a moderator:
Upvote 0
Solution
Try this macro. You must set the following references, via Tools -> References, in the VBA editor:

Microsoft HTML Object Library​
Microsoft Internet Controls​

VBA Code:
Public Sub IE_Test()

    Dim IE As InternetExplorer
    Dim HTMLdoc As HTMLDocument
    Dim dropdown As HTMLInputElement
    Dim searchButton As HTMLDivElement
    Dim nextPage As HTMLTableCell
    #If VBA7 Then
        Dim changeEvent As DOMEvent
    #Else
        Dim changeEvent As Object
    #End If
   
    Set IE = New InternetExplorer
    With IE
        .navigate "http://anagrafe.cng.it/anagrafe/geometri.aspx"
        While IE.Busy Or IE.readyState <> READYSTATE_COMPLETE: DoEvents: Wend
        .Visible = True
        Set HTMLdoc = .document
    End With
   
    Set changeEvent = HTMLdoc.createEvent("HTMLEvents")
    changeEvent.initEvent "change", True, False

    Set dropdown = HTMLdoc.getElementById("ctl00_ContentPlaceHolder1_ddlCodiceCollegio_I")
    dropdown.Value = "AGRIGENTO"
    dropdown.dispatchEvent changeEvent
   
    Set searchButton = HTMLdoc.getElementById("ctl00_ContentPlaceHolder1_btnFiltra_CD")
    searchButton.Click
   
    While IE.Busy Or IE.readyState <> READYSTATE_COMPLETE: DoEvents: Wend
       
    Set nextPage = HTMLdoc.getElementsByClassName("dxpButton")(1)
    nextPage.Click
   
End Sub
Not have Words.,!!!!
Pizza margherita!
Tks bro, you save my Life.
 
Upvote 0
Try this macro. You must set the following references, via Tools -> References, in the VBA editor:

Microsoft HTML Object Library​
Microsoft Internet Controls​

VBA Code:
Public Sub IE_Test()

    Dim IE As InternetExplorer
    Dim HTMLdoc As HTMLDocument
    Dim dropdown As HTMLInputElement
    Dim searchButton As HTMLDivElement
    Dim nextPage As HTMLTableCell
    #If VBA7 Then
        Dim changeEvent As DOMEvent
    #Else
        Dim changeEvent As Object
    #End If
 
    Set IE = New InternetExplorer
    With IE
        .navigate "http://anagrafe.cng.it/anagrafe/geometri.aspx"
        While IE.Busy Or IE.readyState <> READYSTATE_COMPLETE: DoEvents: Wend
        .Visible = True
        Set HTMLdoc = .document
    End With
 
    Set changeEvent = HTMLdoc.createEvent("HTMLEvents")
    changeEvent.initEvent "change", True, False

    Set dropdown = HTMLdoc.getElementById("ctl00_ContentPlaceHolder1_ddlCodiceCollegio_I")
    dropdown.Value = "AGRIGENTO"
    dropdown.dispatchEvent changeEvent
 
    Set searchButton = HTMLdoc.getElementById("ctl00_ContentPlaceHolder1_btnFiltra_CD")
    searchButton.Click
 
    While IE.Busy Or IE.readyState <> READYSTATE_COMPLETE: DoEvents: Wend
     
    Set nextPage = HTMLdoc.getElementsByClassName("dxpButton")(1)
    nextPage.Click
 
End Sub
Hummm...
Have Just experince to loop the current table of AGRIGENTO, and store the relative value in a vars?
Naturally, use Just the next code button, the get the complete set of cells?
Sorry me but never used a dom object, and this project Is very important for me, bro.
Tks.
 
Upvote 0

Forum statistics

Threads
1,214,421
Messages
6,119,392
Members
448,891
Latest member
tpierce

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top