Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2009
    Posts
    5

    Unanswered: Access VBA & How to follow shortcut

    Hi - I have managed to create a shortcut to an Access database with the /ro switch added to the Target line - now I would like to use Access VBA to follow the shortcut does anyone have any ideas - I have tried using the Shell to open but no joy.

    Thanks in advance
    Al

  2. #2
    Join Date
    May 2009
    Posts
    258
    Why not just use the Shell command on the target of the shortcut?
    Code:
    Shell "msaccess.exe /ro ""c:\My Folder\My Database.mdb"""
    Regards,

    Ax

  3. #3
    Join Date
    Oct 2009
    Posts
    5
    thanks for reply Ax - I had tried various incarnations of this but I think my quote placing is wrong - the path to the .mdb file is held in a string strFullPath keep getting file not found error though can use the same path to create a shortcut. The latest I tried was:

    Shell "C:\Program Files\Microsoft Office\OFFICE11\Access.exe/ro " & strFullPath

    Thanks Again

  4. #4
    Join Date
    Oct 2009
    Posts
    5

    update

    well Ive got a little further forward. I can run the Shell command:
    Shell ("C:\Program Files\Microsoft Office\Office11\msaccess.exe /ro")
    this starts up an instance of msaccess and accepts the /ro switch.
    The problem now is that when I place the path and file name I want to open in front of it - I get an error message stating that I am using an illegal switch - conatins an option that Microsoft Access doesnt recognise ?
    Path and file name is "C:\My Documents\Security Gateway\MyDb.mdb"
    Anyone got any ideas where I am going wrong ?
    Thanks in Advance

  5. #5
    Join Date
    May 2009
    Posts
    258
    Yeah, you just have problems with quotes, this ought to do it for you:
    Code:
    Shell ("""C:\Program Files\Microsoft Office\Office11\msaccess.exe"" /ro ""C:\My Documents\Security Gateway\MyDb.mdb""")
    In order to get double quotes in a string, you have to double them up or use the char code.

    Ax

  6. #6
    Join Date
    Oct 2009
    Posts
    5

    Smile

    Thanks Ax it was the quotes - working a treat now

Posting Permissions

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