简体   繁体   English

excel VBA-宏以单击IE中的下一页

[英]excel VBA - Macro to click to the next page in IE

I cannot figure out how to click the "Next 100" button on this page: 我无法弄清楚如何单击此页面上的“下一个100”按钮:

http://www.sec.gov/cgi-bin/browse-edgar?action=getcompany&CIK=0000898293&type=&dateb=&owner=exclude&count=100 http://www.sec.gov/cgi-bin/browse-edgar?action=getcompany&CIK=0000898293&type=&dateb=&owner=exclude&count=100

specifically this section: 特别是本节:

<form>
     <table border="0" width="100%">
        <tbody><tr>
           <td>Items 1 - 100&nbsp;&nbsp;<a href="/cgi-bin/browse-edgar?action=getcompany&amp;CIK=0000898293&amp;type=&amp;dateb=&amp;owner=exclude&amp;start=0&amp;count=100&amp;output=atom"><img src="/images/rss-feed-icon-14x14.png" alt="0000898293 Filings" border="0" align="top"> RSS Feed</a></td>
           <td style="text-align: right;"> <input type="button" value="Next 100" onclick="parent.location='/cgi-bin/browse-edgar?action=getcompany&amp;CIK=0000898293&amp;type=&amp;dateb=&amp;owner=exclude&amp;start=100&amp;count=100'"></td>
        </tr>
     </tbody></table>
  </form>

Below is what I have tired in excel VBA, I don't have a strong understanding of this and know how to click a button if I can see the element id. 以下是我对excel VBA感到厌倦的内容,对此我不太了解,并且如果我可以看到元素ID,则知道如何单击按钮。

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


Dim objTag As Object
For Each objTag In Doc.getElementsByTagName(strTagName)
If InStr(objTag.outerHTML, "Next 100") > 0 Then

    objTag.Click
    objTag.FireEvent ("onclick")

    Exit For

End If
Next

This should work for you: 这应该为您工作:

Sub dates()
    Dim IE As New InternetExplorer

    Set IE = CreateObject("InternetExplorer.Application")

    IE.Visible = True
    IE.Navigate "http://www.sec.gov/cgi-bin/browse-edgar?action=getcompany&CIK=0000898293&type=&dateb=&owner=exclude&count=100"

    Do
        DoEvents
    Loop Until IE.ReadyState = READYSTATE_COMPLETE

    With IE.document
        Set elems = .getElementsByTagName("input")
        For Each e In elems
            If e.Type = "button" And e.Value = "Next 100" Then
                e.Click
                Exit For
            End If
        Next e
    End With
End Sub

If you are using following link : 如果您使用以下链接:

http://www.sec.gov/cgi-bin/browse-edgar?CIK=JBL&owner=exclude&action=getcompany

you'll have to check for 您必须检查

If objCollection(i).Type = "button" And objCollection(i).Value = "Next 40" Then

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM