Our training courses

Other training resources

Our training venues

Why we are different

Details for M G Joshi

M G Joshi has participated in the following threads:

Added by M G Joshi on 09 Oct 2019 at 21:21

Dear Sir  -- when running the following code I get the VBA error
>>> Run Time error '91'
>>> Object variable or With block variable not set

Sub ScrapeOddsUsingXMLHTTP()

    Dim XMLRequest As New MSXML2.XMLHTTP60
    Dim HTMLDoc As MSHTML.HTMLDocument
    Dim HTMLDiv As MSHTML.IHTMLElement
    Dim HTMLTable As MSHTML.IHTMLElement
    
    XMLRequest.Open "GET", "https://www.oddschecker.com/golf/houston-open/winner", False
    XMLRequest.send
    
    If XMLRequest.Status <> 200 Then
        MsgBox XMLRequest.Status & " - " & XMLRequest.statusText
        Exit Sub
    End If
    
    HTMLDoc.body.innerHTML = XMLRequest.responseText   ' <== Code breaks down at this point
    
    Set HTMLDiv = HTMLDoc.getElementById("oddsTableContainer")
    Set HTMLTable = HTMLDiv.getElementsByTagName("table")(0)
    
    Debug.Print HTMLTable.className
End Sub

Any suggestions?  Thank you.

Added by M G Joshi on 08 Oct 2019 at 14:53

Dear Sir

Firstly thank you for your excellent videos

For the Example shown in Video 47 both your procedures …

1.      Sub BrowseToExchangeRatesWithQueryString() and

2.      Sub BrowseToExchangeRatesWithQueryStringAndXML()

produce the same results for the statement for the url, https://www.x-rates.com/table/?from=EUR&amount=3 … namely …

Debug.Print HTMLTables.Length --> displays 2 for the number of tags with the name “table” for both procedures.

However, for the following url, https://www.wsj.com/market-data/commodities with has 3 tables with the tag name “table”

Debug.Print HTMLTables.Length --> displays 3 for only the QueryString (procedure 1) and shows 0 for the QueryStringAndXML (procedure 2)

Could you kindly explain why this is the case?  Thank you

Head office

Kingsmoor House

Railway Street

GLOSSOP

SK13 2AA

London

Landmark Offices

99 Bishopsgate

LONDON

EC2M 3XD

Manchester

Holiday Inn

25 Aytoun Street

MANCHESTER

M1 3AE

© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.

End of small page here
Please be aware that our website uses cookies!
I'm OK with this Tell me more ...