小编exc*_*i11的帖子

当按钮没有关联的“名称”时,请使用Excel VBA在Internet Explorer中单击按钮

我正在尝试使用excel自动在时间表中输入值。时间表在网页上。现在,我可以加载页面,输入我的用户名和密码,然后自己输入时间表。请参见下面的代码。

此时,我需要单击一个按钮以打开子表单。我不知道将要打开多少个子表单。我知道当按钮具有“名称”时如何单击。但是在这种情况下,没有任何东西。因此,我下面的更新代码使用循环来打开其他所有子窗体。第一次起作用,但是当我再次起作用时

有人可以指出我如何确定页面中有多少个按钮以及如何单击每个按钮吗?在放置直到现在及其下方的代码之后,我才需要与之交互的页面的HTML代码。

Private Sub time_sheet_filling()

    Dim I As Long
    Dim IE As Object
    Dim doc As Object
    Dim objElement As Object
    Dim objCollection As Object

    ' Create InternetExplorer Object
    Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = True

    ' Send the form data To URL As POST binary request
    IE.navigate "http://timesheet.cccc.ca/timesheet/"

    ' Wait while IE loading...
    Do While IE.Busy
        Application.Wait DateAdd("s", 1, Now)
    Loop

        'Load the logon page
    Set objCollection = IE.Document.getElementsByTagName("input")
    I = 0
    While I < objCollection.Length
        If objCollection(I).Name …
Run Code Online (Sandbox Code Playgroud)

html excel internet-explorer vba web-scraping

3
推荐指数
1
解决办法
8万
查看次数

标签 统计

excel ×1

html ×1

internet-explorer ×1

vba ×1

web-scraping ×1