0

I want to check the availability of an item @ www.bgstechnic.com/availability

for instance "1195"

I wrote this VBA code:

Sub ImportMyData()

    Dim IE As New InternetExplorer
    
    IE.Visible = False
    IE.navigate "http://www.bgstechnic.com/availability?processed&F1244467957750MNRHTT=_"
    
    Do
        DoEvents
    Loop Until IE.readyState = READYSTATE_COMPLETE
    
    IE.document.getElementById("item-numbers").Value = "1195"
    
    Set goBtn = IE.document.getElementById("bgs-submit")
    goBtn.Click
    
    Do
        DoEvents
    Loop Until IE.readyState = READYSTATE_COMPLETE
    
    Dim sdd As String
    sdd = IE.document.getElementById("availability-results").innerText
    
    MsgBox sdd

End Sub

I need the text "Item in in stock, more than 50 pcs. available" to be inserted in Excel, but I don't manage to find the ID of this subtable (?)

Community
  • 1
  • 1
Justas Mundeikis
  • 935
  • 1
  • 10
  • 19
  • Now its weird: if I change to "sdd = IE.document.getElementsByTagName("td")(1).innerText" i get run time error 91, but by pressing f5 and running further, i get the message with the available quantity... any clou how to solve this? – Justas Mundeikis Dec 30 '14 at 11:36

1 Answers1

0

You have to drill down farther by class-name. Try this:

sdd = IE.Document.getElementsByClassName("availability-desc")(0).innerText

Which will return the description of row (0) from the availability column. This should work, but (disclaimer) I have not tried it due to some #!@#!# IE issues ;)

ChE Junkie
  • 326
  • 2
  • 9
  • Unfortunately, in that case I receive an error: Run-time error 428. Object doesn't support this property or method. My I-explorer has version 11. – Justas Mundeikis Dec 30 '14 at 10:30
  • IE 11 does support this method (see http://caniuse.com/#feat=getelementsbyclassname), I may have gotten the call structure wrong though. A quick search: maybe try something like e.g. http://stackoverflow.com/questions/20205442/excel-vba-get-inner-text-of-html-table-td – ChE Junkie Dec 31 '14 at 04:45