Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2010
    Provided Answers: 4

    Question Answered: Command to launch Google Maps?

    Hi All

    I've had a request from a user to implement a button an a foprm that when pressed would send an address directly to Google Maps.

    I have found that you can send a command line to google maps using[insert address information here]

    I can collect the required address info from my table, but am unsure about how to execute the command in Access

    Has anyone attempted something like this that might be able to point me in the right direction.

    I'm using MS Access 2003 & 2007

    Thanks in advance.

  2. Best Answer
    Posted by sheusz

    "Hello Raman256

    Thank you very much. Absolutely perfect. Works brilliantly."

  3. #2
    Join Date
    Apr 2014
    Provided Answers: 32
    Paste this code into a module, and it will open ANY file in its native application.

    usage: OpenNativeApp "c:\folder\file.pdf"
    will open it in acrobat
    OpenNativeApp ",+Washington,+DC+20500"
    will open the explorer to the address.

    'Attribute VB_Name = "modNativeApp"
    'Option Compare Database
    Option Explicit
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long
    Private Declare Function GetDesktopWindow Lib "user32" () As Long
    Const SW_SHOWNORMAL = 1
    Const SE_ERR_FNF = 2&
    Const SE_ERR_PNF = 3&
    Const SE_ERR_OOM = 8&
    Const SE_ERR_DLLNOTFOUND = 32&
    Const SE_ERR_SHARE = 26&
    Const SE_ERR_DDETIMEOUT = 28&
    Const SE_ERR_DDEFAIL = 29&
    Const SE_ERR_DDEBUSY = 30&
    Const SE_ERR_NOASSOC = 31&
    Const ERROR_BAD_FORMAT = 11&
    Public Sub OpenNativeApp(ByVal psDocName As String)
    Dim r As Long, msg As String
    r = StartDoc(psDocName)
    If r <= 32 Then
        'There was an error
        Select Case r
            Case SE_ERR_FNF
                msg = "File not found"
            Case SE_ERR_PNF
                msg = "Path not found"
            Case SE_ERR_ACCESSDENIED
                msg = "Access denied"
            Case SE_ERR_OOM
                msg = "Out of memory"
            Case SE_ERR_DLLNOTFOUND
                msg = "DLL not found"
            Case SE_ERR_SHARE
                msg = "A sharing violation occurred"
                msg = "Incomplete or invalid file association"
            Case SE_ERR_DDETIMEOUT
                msg = "DDE Time out"
            Case SE_ERR_DDEFAIL
                msg = "DDE transaction failed"
            Case SE_ERR_DDEBUSY
                msg = "DDE busy"
            Case SE_ERR_NOASSOC
                msg = "No association for file extension"
            Case ERROR_BAD_FORMAT
                msg = "Invalid EXE file or error in EXE image"
            Case Else
                msg = "Unknown error"
        End Select
    '    MsgBox msg
    End If
    End Sub
    Private Function StartDoc(psDocName As String) As Long
    Dim Scr_hDC As Long
    Scr_hDC = GetDesktopWindow()
    StartDoc = ShellExecute(Scr_hDC, "Open", psDocName, "", "C:\", SW_SHOWNORMAL)
    End Function

  4. #3
    Join Date
    Sep 2010
    Provided Answers: 4


    Hello Raman256

    Thank you very much. Absolutely perfect. Works brilliantly.

  5. #4
    Join Date
    Mar 2015

    Excellent answer indeed

    Thanks for this! I too have needed the answer to this question for a back burnered personal db project.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts