Use VBA code to click on a button on webpage

柔情痞子 提交于 2019-11-28 12:43:06

Perhaps something on the lines of:

Set tags = wb.Document.GetElementsByTagname("Input")

For Each tagx In tags
    If tagx.alt = "File_Certificate_Go" Then
        tagx.Click
    End If
Next

Where wb is the WebBrowser control.

Is there a reason you couldn't give the element an id?

i.e.:

<input id='myButton' type=image src="/lihtml/test_button3.gif" align=left alt=File_Certificate_Go> 

then:

document.getElementById('myButton').click()

edit: Based on your comment, you'd have to grab all input elements on the page, and then cycle through them looking for the one that makes your input unique:

var elms = document.getElementsByTagName("input"); 
for (var i=0; i< elms.length; i++) 
    if(elms[i].src = '/lihtml/test_button3.gif') { elms[i].click(); }

Something along those lines anyway

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!