I have this code which is working fine, but come up with Quota Limit and stops returning lat longs
I have been told that I need to use an API key which I now have, but I am not sure how I incorporate the Key into the code below to stop quota limit coming up.
I have been told that I need to use an API key which I now have, but I am not sure how I incorporate the Key into the code below to stop quota limit coming up.
Code:
Function lat_lon(a_t As String, c_t As String, s_t As String, co_t As String, z_t As String, la_t As String, lo_g As String)
Dim sURL As String
Dim BodyTxt As String
Dim apan As String
'la_t As String, lo_g As String
Dim oXH As Object
'create web url
sURL = "http://maps.googleapis.com/maps/api/geocode/xml?address="
sURL = sURL & Replace(a_t, " ", "+") & ",+" & Replace(c_t, " ", "+") & ",+" & Replace(s_t, " ", "+") & _
",+" & Replace(co_t, " ", "+") & ",+" & ",+" & Replace(z_t, " ", "+") & ",+" & _
"&sensor=false"
' browse url
Set oXH = CreateObject("msxml2.xmlhttp")
With oXH
.Open "get", sURL, False
.Send
BodyTxt = .RESPONSETEXT
End With
apan = Application.WorksheetFunction.Trim(BodyTxt)
'Latitude
apan = Right(apan, Len(apan) - InStr(1, apan, "<lat>") - 4)
la_t = Left(apan, InStr(1, apan, "</lat>") - 1)
'Longitude
apan = Right(apan, Len(apan) - InStr(1, apan, "<lng>") - 4)
lo_g = Left(apan, InStr(1, apan, "</lng>") - 1)
'lat_lon = "Lat:" & la_t & " Lng:" & lo_g
End Function