'finds the longitude of a postcode
'max 650 queries per 24 hours
Function lon(z_t As String)
Dim sURL As String
Dim BodyTxt As String
Dim apan 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(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)
'Longitude
apan = Right(apan, Len(apan) - InStr(1, apan, "<lng>") - 4)
lo_g = Left(apan, InStr(1, apan, "</lng>") - 1)
lon = lo_g
End Function
'finds the latitude of a postcode
'max 650 queries per 24 hours
Function lat(z_t As String)
Dim sURL As String
Dim BodyTxt As String
Dim apan As String, la_t As String
Dim oXH As Object
'create web url
sURL = "http://maps.googleapis.com/maps/api/geocode/xml?address="
sURL = sURL & 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)
lat = la_t
End Function