Determining if HTML Button is Disabled in IE

若如初见. 提交于 2020-08-04 14:44:33

问题


I'm doing some VBA recently for work and I need to check in a webpage to click a button if is enable and don't click if is disabled.

BUT! I don't know how to make VBA check the disabled button.

Here is the button code:

<input name="formAction:proxima" title=">" disabled="disabled" class="button" id="FormAction:proxima" type="submite" value=">">

I tried some If, but didn't work

    Set nxt = IE.document.getElementById("formAction:proxima")

    If nxt Is Nothing Then
        IE.Quit
    Else
        nxt.Click
    End If

回答1:


You can also use the .disabled property (Boolean).

Dim nxt As HTMLButtonElement
Set nxt = IE.document.getElementById("formAction:proxima")

If nxt.disabled Then
    ie.Quit
Else
    nxt.Click
End If



回答2:


You need to access the button disabled property. Try this:

Set nxt = IE.document.getElementById("formAction:proxima")

If nxt.getAttribute("disabled") = "disabled" Then
     IE.Quit
Else
     nxt.Click
End If


来源:https://stackoverflow.com/questions/49330011/determining-if-html-button-is-disabled-in-ie

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