在VBA上单击没有ID的按钮即可在IE上使用 [英] click button without id on vba to use on IE

查看:435
本文介绍了在VBA上单击没有ID的按钮即可在IE上使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图点击一个没有ID或Name的按钮;我尝试使用制表符,但是没有用,并且尝试了以下代码,但是它什么也没做:

I'm trying to made a click on a button that does not have an ID or a Name; I tried using tabs, but it didn't work, and I tried the following code, but it doesn't do anything:

Set tags = Ie.document.getElementsByTagName("button")
For Each tagx In tags
    If tagx.Value = "Save" Then
        tagx.onclick
        Exit For
    End If
Next

这是HTML标记:

<div class="ui-dialog-buttonpane ui-widget-content ui-helper-clearfix">
  <div class="ui-dialog-buttonset">
    <button type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false"><span class="ui-button-text">Cancel</span></button>
    <button type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false"><span class="ui-button-text">Save</span></button>
  </div>
</div>

推荐答案

tagx.Value始终为空.在此处检查"HTML按钮值"属性信息.

The tagx.Value is always empty. Check Html-Button Value attribute information here.

按钮中似乎包含Span文字 Save Cancel ,因此您可以检查tagx.innerText来找到保存按钮,然后调用Click方法.

The buttons seems to have Span with text Save or Cancel inside of it so you could check for tagx.innerText to find the save button and then call Click method on it.

Set tags = ie.document.getElementsByTagName("button")
For Each tagx In tags
    If tagx.innerText = "Save" Then
        tagx.Click
        Exit For
    End If
Next

这篇关于在VBA上单击没有ID的按钮即可在IE上使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆