Results 1 to 7 of 7
  1. #1
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544

    Question Call Shell() syntax

    It's been a while since I used this and I'm embarrassed to say I cannot remember how to use it. I'm trying to open another Access DB on a network drive. Thank you.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Was VBA help not helpful? It would look like:

    Call Shell("C:\Programs\...\MSACCESS.EXE \\ServerName\...\FileName.MDE", 1)

    If memory serves, you might be able to get away with just the name of the executable, rather than the full path to it. Generally speaking you should have the Access db on the local PC, not a network drive.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    couldn't you also use the:
    Code:
    dbengine.opendatabase
    method?

  4. #4
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Kinda dropped the ball on this thread! I tried pbaldy's method. Got a runtime '5' error. I'm not familiar with the "dbenginge.opendatabase" method, but I tried the below code...no luck

    Code:
        Dim vAppName As String, vAppLoc As String
        vAppName = "Database1.mdb"
        vAppLoc = "C:\Data\" & vAppName
        DBEngine.OpenDatabase vAppLoc

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    We would have to see the actual code to know why you got an error. You can also use FollowHyperlink, which doesn't require a path to the executable.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Ended up finding the solution...Thank you Google!

    Code:
    Call Shell("""" & "C:\Program Files\Microsoft Office\OFFICE14\MSACCESS.exe" & """" & " " & """" & vAppLoc & """", vbMaximizedFocus)
    Can anyone explain the need for all those " and spaces?

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The quotes are required due to spaces in the path to the file (I suspect only the file path, not the executable path, because Shell works for me without all the quotes, but I don't have spaces in the file path).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Shell with Batch Variables
    By robbyaube in forum Programming
    Replies: 2
    Last Post: 12-19-2019, 11:06 AM
  2. Incomplete Syntax Clause (syntax error)
    By ajetrumpet in forum Programming
    Replies: 4
    Last Post: 09-11-2010, 10:47 AM
  3. Open (shell) a program and pass a file
    By Olszanski in forum Programming
    Replies: 2
    Last Post: 07-27-2010, 03:52 PM
  4. Replies: 4
    Last Post: 05-20-2010, 03:49 AM
  5. how to call a sub procedure?
    By dollygg in forum Access
    Replies: 1
    Last Post: 08-18-2009, 05:10 AM

Tags for this Thread

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