Excel VBA create links to Google Maps


I came across this idea when the system I was working on a system that gave locations in Eastings and Northings. These need converting to longitude and latitude and then they can be used to link to a map of the location. You really do need 13 decimal places to geolocate to the middle of a road. The first line of code is used to enter the hyperlink in the cell. The function is used in Access to generate the string value of the URL.

Here is the link to the calculations to convert Eastings and Northings to Latitude and Longitude for Google Maps

http://www.tek-tips.com/viewthread.cfm?qid=1659914

    ActiveSheet.Hyperlinks.Add _
    	Anchor:=Selection, _
    	Address:="https://maps.google.com/?q=54.0344715537889,-1.08377376116491", _
    	TextToDisplay:="https://maps.google.com/?q=54.0344715537889,-1.08377376116491"

	Public Function fnGoogleMaps(iEastings As Long, iNorthings As Long) As String
	 Dim LL As LatLong
	 Dim EN As EastingNorthing
	 fnGoogleMaps = ""
	 If iEastings > 0 Then
	   EN.Easting = iEastings
	   EN.Northing = iNorthings
	   LL = getLatLong(EN)
	   fnGoogleMaps = "https://maps.google.com/?q=" & _
	   		decDegFromRadians(LL.Lattitude) & "," & _
	   		decDegFromRadians(LL.Longitude)
	 End If
	End Function


Tags - Excel 2010, Excel 2007, Access 2010, Access 2007, Google Maps, VBA, code, Microsoft, Visual BASIC for Applications, eastings, northings, longitude, latitude, conversion, link, decimal, places, geolocate, hyperlink, location...