1

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.

QHarr
  • 83,427
  • 12
  • 54
  • 101
David912
  • 378
  • 1
  • 2
  • 11
  • Where is your code to reproduce this problem please? – QHarr Sep 06 '18 at 08:45
  • I did not post any code because it seems the problem is with IE as explained in the link: "The problem appears when a form only has input elements without a name attribute (or no input elements)." Is there a way for scarping data with VBA without using Internet Explorer maybe? – David912 Sep 06 '18 at 08:51
  • 1
    yes.... which is why I am asking for your code. Seeing an URL and understanding what you are after from the page. It maybe we can use one of the fixes from that link. – QHarr Sep 06 '18 at 08:54
  • 1
    I think your only option is to use selenium VBA – Margon Sep 06 '18 at 08:56
  • @QHarr open this link with IE (Sorry that everything is in Hebrew...) 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 enter something in the search box and try to click the red button - you will see that it does not response (you should be getting an error message at least). If there is a way to manually get this button to work I believe I can take it from there. If you still have to see the code I will post it as well. – David912 Sep 06 '18 at 09:04
  • Would you be open to a selenium vba answer? Can you install selenium basic on your machine? – QHarr Sep 06 '18 at 09:21
  • Also, should there be info that appears on the same page underneath the button whe it is pushed or a new window that opens? – QHarr Sep 06 '18 at 09:37

1 Answers1

1

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
QHarr
  • 83,427
  • 12
  • 54
  • 101
  • Removing IE from the equation is just what I need. I downloaded selenium basic, which file exactly should I make a reference to? Where is this library located? – David912 Sep 06 '18 at 10:44
  • 1
    selenium basic will prompt for installation then you open the Visual Basic Editor (where you type code) and at the top go tools > references > and in the box that appears scroll down until you find Selenium Type Library and check that box. – QHarr Sep 06 '18 at 10:46