Search code examples
vbaexcelgeocodinglatitude-longitudegoogle-earth

Geocoding using Google Earth


I would like to get a pair of coordinates (longitude, latitude) from a postal address.

I am coding VBA in an Excel workbook. I can assume that Google Earth is installed and registered as COM server. Thus I have been looking for a way to use the Google Earth COM API to achieve this, however I have not managed to find anything.

Most of the hits I found on the web are for web programmers and are about using the "Google geocoding API" which is JavaScript, which I think is not feasible for my case.

(Update: This was to be done as a batch job for dozens/hundreds of addresses. As rjmunro pointed out, it's private and thus against the Google terms of use, so I had to look for a different service.)


Solution

  • Why do you want to use Google Earth? It can't geocode if the computer is not online, and if it is online, you may as well use the web apis directly. There are lots of examples of using VBA to access geocoding apis on the web, both with Google, and with other providers (Bing, Yahoo, etc.).

    Note that if this is for a private application, rather than one that anyone can download, it may be against the Google terms of service, and you may need to use a different provider. See this question in Google's FAQ.