0
votes

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 (?)

1
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

1 Answers

0
votes

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 ;)