Opening Google Street View in VBA Excel

Open Street View from Excel

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 of a supplement to 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 in 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 the 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 the 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/

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *