Results 1 to 3 of 3
  1. #1
    bid19123 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2016
    Location
    Cayman Islands
    Posts
    15

    Open external program and file using VBA

    I am using the following code from within Access to try and open a specific file that will show data from the database on a map. Not sure why I get an error stating :



    Could not find file L:\R&D.mxd

    I don't see how I have asked it to open this file.

    I am using Access 2010 and the program and file paths are correct. The file part of the code works as the application does open; it just doesn't open the file I want.

    Code:
    Private Sub Command0_Click()
     Dim x As Variant
        Dim Path As String
        Dim File As String
    
    
        Path = "C:\Program Files (x86)\ArcGIS\Desktop10.2\bin\ArcMap.exe"
        File = "L:\R&D Section\Databases\Access databases\2016 survey\zika cases.mxd"
    
    
        x = Shell(Path + " " + File, vbNormalFocus)
    
    
    End Sub

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Does this work outside of Access? If you typed that in to a Run command for instance.

  3. #3
    bid19123 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2016
    Location
    Cayman Islands
    Posts
    15
    Thanks aytee111 I think I figured it out. The file path has spaces and therefore I needed to add double quotes to the file path:

    Now it works!

    File = """L:\R&D Section\Databases\Access databases\2016 survey\zika cases.mxd"""

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Open external file with command button
    By bradp1979 in forum Programming
    Replies: 47
    Last Post: 08-20-2015, 05:33 PM
  2. Open file with non default program
    By LonghronJ in forum Modules
    Replies: 1
    Last Post: 08-15-2015, 10:10 AM
  3. Replies: 3
    Last Post: 12-24-2014, 11:47 AM
  4. Open External program with vba
    By aspen in forum Programming
    Replies: 3
    Last Post: 04-09-2014, 06:08 AM
  5. Open (shell) a program and pass a file
    By Olszanski in forum Programming
    Replies: 2
    Last Post: 07-27-2010, 03:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums