Advertisements

An original point of view

GIS

Opening Google Street View in VBA Excel

Open Google Street View from Excel

Opening Google Street View from Excel when coordinates are known.

Opening websites programmatically at their certain addresses is quite a straightforward thing regardless of the programming language. Previously I dealt with launching Google Maps from the Excel document with the Google Chrome browser.  Now I would like to explain to you briefly the option, which allows you to open the Street View image anywhere you want. The basis remains the same. You have to define the coordinates earlier – from the position of your spreadsheet. For clarity, this is one of at least two other ways to link Google Street View with your Excel worksheet. In other cases, you can (or at least you could before 2018) open the Street View by hyperlink or even embed the Street View frame into your worksheet, which appears to be much more snazzy.
I won’t deal with them now, but you can visit the links attached below. My article will be somewhat the supplement of the previous one discussed earlier.

The key link here looks like this:

http://maps.google.com/maps?q=&layer=c&cbll=YOUR_COORDINATES

To get your coordinates you can use the geocoding tools for Excel discussed across a few articles previously. You can do it for free by using Bing or Nominatim if they are not provided directly.
An example cell with the coordinates prepared for the Google Street View permalink format should look like this:

52.26417397666667,0.19245357373808164

which is roughly the result of Nominatim geocoding function.

Finally, the full VBA code will be in the following form:

Sub GoogleStreetView()

Dim Coordinates As String

Dim url As String

Coordinates = Sheets("Frontsheet").Range("AE2").Value ' The cell with coordinates

url = "https://www.google.com/maps?q=&layer=c&cbll=" & Coordinates

OpenChrome url

End Sub

Sub OpenChrome(URL As String)
Dim Chrome As String
Chrome = "C:\Program Files (x86)\Google\Chrome\Application\Chrome.exe -url"
Shell (Chrome & " " & URL)
End Sub

which next triggers the Google Street View to open in the Chrome browser exactly at the pace of coordinates defined (Pic. 1).

Google Street View opened from Excel

Pic. 1 Google Street View opened from Excel. The permalink contains the coordinates defined in the spreadsheet cell.

Mariusz Krukar

Links:

  1. Google Maps & Street View panorama

Forums:

  1. Mrexcel.com: Automating going to Google Street View
  2. https://stackoverflow.com/questions/33573556/embed-a-google-street-view-image-into-excel
  3. https://www.reddit.com/r/excel/comments/6ygwyv/how_to_add_google_maps_street_view_in_excel/
Advertisements

Leave a Reply