-2

I have a code that already searches for the latitude and longitude and pastes to my worksheet, which works perfectly. I'm looking for a way to take that latitude and longitude, load google maps, and either take a screenshot of the google maps page or embed the map into Excel.

In my code below I have a code that already loads google maps for any input address, but I do not know how to either take the screenshot of the map (preferably without the input information on the side of the page) or embed the map into Excel. The extra code at the bottom is for a request/response from a USGS website that pulls official seismic information for a location, but should not effect the top part of the code.

Please note that I want this to just be a static screenshot of the map if possible. I do not want to install Google Earth on multiple desktops to be able to embed an interactive map into the worksheet if at all possible.

Option Explicit

Public Sub Seismicgrab()

Dim browser As New ChromeDriver
Dim URL As String
Dim ws As Object
Dim xmlhttp As New MSXML2.XMLHTTP60

browser.Get "http://www.google.com/maps?q=" & Range("H13").Value

browser.Wait 5000

Cells(19, 13).Value = browser.URL

browser.Close

URL = Range("M24").Value
xmlhttp.Open "GET", URL, False
xmlhttp.Send
Worksheets("Title").Range("M25").Value = xmlhttp.responseText
End Sub
QHarr
  • 83,427
  • 12
  • 54
  • 101
Andrew Bishop
  • 37
  • 1
  • 8
  • I had looked at that post previously. In that post, aren't they installing Google Earth on their desktop and using that to show the interactive map? I was aiming for just a static screenshot where I don't have to install anything on someone's desktop because multiple people will be using this on different desktops. – Andrew Bishop Dec 13 '18 at 15:50
  • no the first answer uses a webbrowser control to dynamically show the most recent map of google maps. If you have a screenshot it will be static and will never update, the webbrower control needs an internet connection but then show the most recent map. Don't know if this meets your needs. – Pᴇʜ Dec 13 '18 at 15:55

1 Answers1

0

You can use the TakeScreenshot method of the object

browser.TakeScreenshot.SaveAs ".....jpg"   '<== put your path and file name here

For more flexibility e.g. cropping consider switching languages and using any of these methods:

How to capture the screenshot of a specific element rather than entire page using Selenium Webdriver?

Additionally, there are ways I believe with standard VBA and API calls to take a screenshot and then crop an image.

QHarr
  • 83,427
  • 12
  • 54
  • 101