Simon Lee
Simon Lee

Reputation: 11

Excel 2016 - User-defined type not defined

Am stumped with a BingMaps API Compile error, Basically it runs in Microsoft Office 2010 without issue, however when I try and run this in Office 2016 it fails to run and thought's a vba debug error.

Function GetDistance(sPCode As String, ePcode As String) As Double
    Dim t As String
    Dim re As XMLHTTP

    t = "http://dev.virtualearth.net/REST/V1/Routes/Driving?o=xml&wp.0=" & sPCode & "&wp.1=" & ePcode & "&avoid=minimizeTolls&du=mi&key=AjfyHbOP6UDABNbXmV59momsvs6cRqjrIz4g0bbsmGyBAJz1TgTgqRXS_PfWcm5k"

    Set re = New XMLHTTP

    re.Open "get", t, False
    re.send
    Do
    DoEvents
    Loop Until re.readyState = 4

    With re
        s = Split(.responseText, "<TravelDistance>")
    End With

    GetDistance = Val(s(1))

End Function

Upvotes: 1

Views: 490

Answers (1)

James Dodd
James Dodd

Reputation: 11

I was having the same problem!

Not sure if this will work for you, but on tools, references deselect Microsoft XML V6 and select V3.0.

that's worked for me.

Regards

Upvotes: 1

Related Questions