# Access 2003 - Correct Use of VBA "Shell" command



## Chris_E (Feb 16, 2006)

In my VBA script, I have a section associated with an onclick event in my Access form. Onclick, I want to run Adobe Acrobat and open a specific PDF file.

Now I have this code (paths for 'Filename' is an example)

Dim RetVal
Dim Filename As String

Filename = "C:\ManualRevA.pdf"

RetVal = Shell("C:\Program Files\Adobe\Adobe Acrobat 6.0\Acrobat\acrobat.exe " & Filename, 1)

This is ok for the filename as I'll be using InstallShield to fix the location of the PDF. The problem arises with the path for Acrobat itself. If the client is running version 6 or 7, the text for the path is different.

I saw a reference to on a different website to the start command (which works at the DOS level)

Shell "start C:\ManualRevA.pdf"

This would allow the VBA to call up the PDF without the acrobat.exe element, it uses the file type to determine the correct application.

Trouble is I can't figure the syntax for the "Shell start... " command so its not working for me and I'd like it to!

Can anyone help?

Thx in advance

Chris


----------



## Rollin_Again (Sep 4, 2003)

What don't you just use an *IF / ELSE* statement to determine which path to use depending on whether the Adobe 6.0 directory exists?

Rollin


----------



## cristobal03 (Aug 5, 2005)

In the command prompt, you can type *start /?* for more usage information. It looks like what you have there is correct. However, you'll have some major problems if there are any spaces in the filename. What sort of behavior are you seeing at the moment?

chris.


----------



## Ivan F Moala (Dec 26, 2004)

you can also lauch it via Rundll

Sub LaunchApp()
'// Windows 2000,Windows XP,Windows 2003
'// Launch any registered application (.exe, .doc, etc).

Shell "RunDLL32.EXE shell32.dll,ShellExec_RunDLL C:\ExcelFiles\match-schedule-wm-2006,property=publicationFile.pdf "


End Sub


----------



## GTAdoum (Apr 30, 2008)

Shell "cmd.exe /c Start ""Window title"" ""path to file\file.ext""", vbHide

Double quotes to pass as a single quote, in case of spaces...


----------

