David912
David912

Reputation: 396

A bug in IE prevents my VBA macro from running

I have a VBA macro for fetching data from a web page that has been working fine for the past few months. This morning it stopped working. The problem is that when I click a button to submit a form nothing happens. I tried to manually click the button without automation and still nothing happens.

I looked it up and found this old thread which describes the problem: IE11-Only Submit Bug.

So it appears that this is known issue with IE but that does not help me much. Any suggestion on what can I do to have my macro running again? Every tutorial I tried to read uses IE for automation so I am stuck here.

Upvotes: 1

Views: 53

Answers (1)

QHarr
QHarr

Reputation: 84465

The following works using Chrome and selenium basic. After installing selenium basic you need to go VBE>Tools>References and add a reference to Selenium Type Library. You have then removed IE from the equation. Selenium basic supports a number of other browsers including FireFox and Opera.

Option Explicit
Public Sub EnterInfo()
    Dim d As WebDriver, ele As Object, t As Date
    Set d = New ChromeDriver
    Const URL = "https://mypost.israelpost.co.il/%D7%9E%D7%A2%D7%A7%D7%91-%D7%9E%D7%A9%D7%9C%D7%95%D7%97%D7%99%D7%9D"
    Const WAIT_TIME_SECS As Long = 10

    With d
        .Start "Chrome"
        .get URL

        With .FindElementById("ItemTraceForm")
            .FindElementById("ItemCode").SendKeys 55671234
            .FindElementById("btn-ItemCode").Click
            t = Timer
            Do
                DoEvents
                If Timer - t > WAIT_TIME_SECS Then Exit Do
                Set ele = .FindElementById("result", timeout:=3000)
            Loop While ele.Text = vbNullString
            Debug.Print ele.Text
        End With

        'Other code....
        Stop                                     '<=Delete me later
        .Quit
    End With
End Sub

Upvotes: 1

Related Questions