spikepl
Eledittingent Beliped
- Local time
- Today, 23:39
- Joined
- Nov 3, 2010
- Messages
- 6,142
Victory!!!!!!!!!!!!!!!!!!!!!!!
After scouring the web and fiddling with exotic API's and stuff, I found bits and pieces to at least download a Google static map directly to a file. All my attempts to create a picture/image directly failed. But now at least I can get the map, and pick it up from the file.
The code ran just fine in Access 2007, and did not require any additional references:
For A2010 there is some good news: the ActiveX WebBrowser object has either been extended or replaced, so one can seemingly save an image from it directly: http://www.databasestation.net/2010/12/14/save-a-google-map-programmatically/
After scouring the web and fiddling with exotic API's and stuff, I found bits and pieces to at least download a Google static map directly to a file. All my attempts to create a picture/image directly failed. But now at least I can get the map, and pick it up from the file.

The code ran just fine in Access 2007, and did not require any additional references:
Code:
Option Compare Database
Option Explicit
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Sub download()
Dim done
Dim URL_base As String
URL_base = "http://maps.google.com/maps/api/staticmap?center=141+Worth+Street,New+York,NY,10013&zoom=18&size=640x640&format=jpg&maptype=hybrid&sensor=false"
done = URLDownloadToFile(0, URL_base, "C:\test.jpg", 0, 0)
If done = 0 Then
MsgBox "File has been downloaded!"
Else
MsgBox "File not found!"
End If
End Sub
Private Sub Command0_Click()
download
End Sub
Last edited: