Hello masters of VBA,
I found this code in https://usefulgyaan.wordpress.com/2015/07/05/reverse-geocoding/
I suppose to let you reverse coordinates into close by addresses. I had done something to put address into coordinates before. I understand to click XML6.0 reference and such. But the code in the site just don't work for me no matter what I do. I looked at few posts here, it did not help any way.
Can someone please point it out for me? What I really wish to do is that have latitude and longitude expressed as "43.840376, -79.037738" in Cell A1 and A2, then return me address in A3
Is there any way? is it not possible? I am sorry if I am asking stupid questions here, as I don't have whole a lot of VBA knowledge. Most of them I have learned from this SITE. Thank you so much for reading!
I found this code in https://usefulgyaan.wordpress.com/2015/07/05/reverse-geocoding/
Code:
Function GEOAddress(dblLatitude As Double, dblLongitude) As String
Dim strJSON As String
Dim strAddress As String
Dim lngTemp As Long
Dim objXml As Object
Dim strUrl As String
strUrl = "http://maps.googleapis.com/maps/api/geocode/json?latlng=" & dblLatitude & "," & dblLongitude & "&sensor=false"
Set objXml = CreateObject("Microsoft.XMLHTTP")
With objXml
.Open "GET", strUrl, False
.send
strJSON = .responseText
End With
Set objXml = Nothing
lngTemp = InStr(1, strJSON, "formatted_address")
strAddress = Mid(strJSON, lngTemp + 22, InStr(lngTemp, strJSON, """,") - (lngTemp + 22))
GEOAddress = strAddress
End Function
I suppose to let you reverse coordinates into close by addresses. I had done something to put address into coordinates before. I understand to click XML6.0 reference and such. But the code in the site just don't work for me no matter what I do. I looked at few posts here, it did not help any way.
Can someone please point it out for me? What I really wish to do is that have latitude and longitude expressed as "43.840376, -79.037738" in Cell A1 and A2, then return me address in A3
Is there any way? is it not possible? I am sorry if I am asking stupid questions here, as I don't have whole a lot of VBA knowledge. Most of them I have learned from this SITE. Thank you so much for reading!