Use Excel VBA to click on a button in Internet Explorer, when the button has no “name” associated

前端 未结 3 1437
[愿得一人]
[愿得一人] 2020-11-30 06:54

I\'m trying to use excel to automate the value entering in a time sheet. The time sheet is on a web page. Right now I\'m able to load the page, enter my username and passwo

3条回答
  •  生来不讨喜
    2020-11-30 07:48

    IE.Document.getElementById("dgTime").getElementsByTagName("a")(0).Click
    

    EDIT: to loop through the collection (items should appear in the same order as they are in the source document)

    Dim links, link 
    
    Set links = IE.Document.getElementById("dgTime").getElementsByTagName("a")
    
    'For Each loop
    For Each link in links
        link.Click
    Next link
    
    'For Next loop
    Dim n, i
    n = links.length
    For i = 0 to n-1 Step 2
        links(i).click
    Next I
    

提交回复
热议问题