VBA clicking a button on IE

Default001

New Member
Joined
Oct 21, 2015
Messages
7
Hi all,

I have the following code that allows me to access the website and select 100 entries per page, although I cannot figure out how to click on the button "Next 100" to access the next page. I tired just navigating to the on click event in the html but that had an error of something like "source already in use". Iv tried searching the internet for answers but cannot find anything helpful. The website is below:

EDGAR Search Results

Code:
Sub dates()Dim IE As New InternetExplorer
IE.Visible = True

IE.navigate "http://www.sec.gov/cgi-bin/browse-edgar?CIK=JBL&owner=exclude&action=getcompany"
Do
 DoEvents
Loop Until IE.readyState = READYSTATE_COMPLETE
Dim Doc As HTMLDocument
Set Doc = IE.document


Doc.getElementById("count").Value = 100
Doc.forms.Item(0).submit
 
There isn't an easy way of referencing the button, because it doesn't have a name or id. It seems to be part of the first form (I haven't looked closely) so try:
Code:
doc.forms(0).getElementsByTagName("INPUT")(0).Click
 
Upvote 0
You don't need to click the button because that page allows you to specify the starting number:

Code:
Sub dates()
Dim IE As New InternetExplorer
IE.Visible = True

Dim start As Long
start = 0

Do
    IE.navigate "http://www.sec.gov/cgi-bin/browse-edgar?CIK=JBL&owner=exclude&action=getcompany&start=" & CStr(start) & "&count=100"
    Do
        DoEvents
    Loop Until IE.readyState = READYSTATE_COMPLETE
    Dim Doc As HTMLDocument
    Set Doc = IE.document
    '....some processing here I guess...
    start = start + 100
Loop Until [some condition]

'....'

End Sub

WBD
 
Upvote 0

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