Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Business Applications Business Applications
Search Search
Search for:
Tech Support Guy > > >

Access 2003 - Correct Use of VBA "Shell" command


(!)

Chris_E's Avatar
Chris_E Chris_E is offline Chris_E has a Profile Picture
Member with 360 posts.
THREAD STARTER
 
Join Date: Feb 2006
Location: Wellingborough, UK
Experience: I have no idea what I don't know - how could I?
09-Jun-2006, 10:05 AM #1
Access 2003 - Correct Use of VBA "Shell" command
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's Avatar
Member with 4,694 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Advanced
11-Jun-2006, 06:53 PM #2
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's Avatar
Member with 3,072 posts.
 
Join Date: Aug 2005
Experience: Advanced
11-Jun-2006, 08:16 PM #3
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's Avatar
Ivan F Moala Ivan F Moala is offline
Junior Member with 5 posts.
 
Join Date: Dec 2004
Location: Auckland, NZ
Experience: Still learning
12-Jun-2006, 06:31 AM #4
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's Avatar
GTAdoum GTAdoum is offline
Junior Member with 1 posts.
 
Join Date: Apr 2008
Experience: Advanced
29-Apr-2008, 09:20 PM #5
Thumbs up VBA Shell with only a file as argument
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...
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
WELCOME TO TECH SUPPORT GUY!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑