how to click the "ok" button on an Internet Explorer alert using VBA?

Asked

Viewed 1,999 times

0

Hello, I have a VBA code that accesses a web page and deletes the entries.

The moment I click the button "delete item" opens an alert on the screen with two buttons ("okay" and "Cancel") and displaying the message "confirm the exclusion of the place of delivery?"

I wanted to know how I do to click the button "okay".

Follows excerpt from the code:

    For Each elements In IE.Document.getElementsByTagName("input")
        If elements.name = "quantidadeTotalInformada" Then
            quantidaeTotal = elements.Value
        End If
    Next

    If quantidaeTotal > 0 Then
        For Each element In IE.Document.getElementsByTagName("a")
            If element.innertext = "Selecione" Then
                element.Click
                Exit For
            End If
        Next
'o popup aparece depois de clicar neste botão
        IE.Document.getElementById("id_btnExcluirLocal").Click 
    End If
  • 1

    not manjo vba but I’ve been seeing around IE.Document.Forms(0). Submit and something like IE.Document.getelementsbyname("subAction")(0). Click

  • I found a way using the Findwindow() to find the popup and the Sendkeys() to send the button click command "okay".

  • but there is a problem, after I click the delete button (IE.Document.getElementById("id_btnExcluirLocal"). Click), the popup appears and the code hangs and only continues if I click (with the mouse), on "okay" or "gate"

  • after waiting a few minutes excel shows the message "microsoft excel is waiting for another application to complete the OLE action "

  • Try giving a Sendkeys to see if it solves

  • Sendkeys even finds the alert that opens it... however if the macro triggers the button "id_btnExcluirLocal" the ie locks the execution of the code and only release if I manually click ok or close the alert

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.