Cannot run a file from Access

  • Thread starter Thread starter Ja
  • Start date Start date
J

Ja

I've converted a database from 97 to 2003 - it comes up with an error - file
not found when i use shell "\DIR\File.pdf"
 
I've added the cmd.exe /c to the beginning of the string. However, this only
brings up a DOS screen. Running Windows XP and Access 2003.
 
\DIR\File.pdf isn't a complete reference to a file. You need either a drive
letter, or a \\server\share in front of that.

If you're trying to get to a subfolder of the folder the database is in,
try:

Application.FollowHyperlink CurrentProject.Path & "\DIR\File.pdf"

(Realistically, I'm surprised it worked in Access 97: you should have been
using FollowHyperlink there as well: Shell is only intended for executables)
 
\DIR\File.pdf isn't a complete reference to a file. You need
either a drive letter, or a \\server\share in front of that.

Are you sure? Won't Windows resolve it relative to the current
directory?

In testing, I found that any valid path that is begun *not* with a \
is OK, dependent on the current directory (CurDir() returns this).

So, if the directory named "DIR" is in the current directory, then
this should work:

Shell("Dir\ExecutableFile.exe")

Of course, how an argument passed to an executable is handled will
depend on how that executable is written.

In the case of trying to open a data file, I'd use the ShellExecute
API, instead (using Dev's HandleFile wrapper,
http://www.mvps.org/access/api/api0018.htm).
 
Thanks, will this work in Access 97 - The computers this database runs on is
using Access 97.
 
David W. Fenton said:
Are you sure? Won't Windows resolve it relative to the current
directory?

In testing, I found that any valid path that is begun *not* with a \
is OK, dependent on the current directory (CurDir() returns this).

So, if the directory named "DIR" is in the current directory, then
this should work:

As you've stated, there are differences between \DIR\File.pdf and
DIR\File.pdf.

\DIR\File.pdf should work, as long as the current drive is correct. (As an
aside, how come there's a ChDrive command, but no CurDrive one?)

DIR\File.pdf should work, as long as the current directory is correct. A
common problem, though, is that CurDir usually isn't what the user (or
developer) thinks it is.
Shell("Dir\ExecutableFile.exe")

Of course, how an argument passed to an executable is handled will
depend on how that executable is written.

In the case of trying to open a data file, I'd use the ShellExecute
API, instead (using Dev's HandleFile wrapper,
http://www.mvps.org/access/api/api0018.htm).

Any particular preference to that API over FollowHyperlink? (Just asking: I
usually use the API, but since it's easier to use FollowHyperlink I've
started recommending that instead)
 
Any particular preference to that API over FollowHyperlink? (Just
asking: I usually use the API, but since it's easier to use
FollowHyperlink I've started recommending that instead)

FollowHyperlink doesn't always work. Secondly, it causes the web
toolbar to appear, and then you have to hide it (who ever needs
it?).
 
The file START.exe is missing off windows XP systems. I copied this file
from my installation CD (which was originally copied of a windows 98
system). (I've forgotten a few things this time - a long time since I've
used Access. I uninstalled Access 2003, Installed Access 97 then
re-installed Access 2003). Now I can open the PDF file. Actually the command
is "Shell c:\DIR\manual.pdf".
 
Back
Top