File Open

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a need to open up various kinds of files upon click on a button.
What would be the best way to do this?

If I use shell (FileName)

where FileName = location+filename like w:\Location\Environment\<filename>

the files could be word document .doc, .pdf,.gif or some other I may not
even know.
If I don't specify the program to open this file for instance
for word document if I have shell (FileName), it doesn't work.
However, if I have shell ("winword " + FileName), it works.

How can I open any file without specifying what program to use?

Thank you,
-Me
 
Me said:
I have a need to open up various kinds of files upon click on a
button. What would be the best way to do this?

If I use shell (FileName)

where FileName = location+filename like
w:\Location\Environment\<filename>

the files could be word document .doc, .pdf,.gif or some other I may
not even know.
If I don't specify the program to open this file for instance
for word document if I have shell (FileName), it doesn't work.
However, if I have shell ("winword " + FileName), it works.

How can I open any file without specifying what program to use?

Thank you,
-Me

Hi, You. <g>

If the files have registered applications, like Word's .doc files, then
you can either use

Application.FollowHyperlink FileName

or call the Windows ShellExecute API using the code at:

http://www.mvps.org/access/api/api0018.htm
API: Start an app with ShellExecute

Most often, FollowHyperlink is all you need.
 
Back
Top