Opening another Program & its file

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

Guest

Hello,

I have an application that I am working on where the user will attach files
& then I need the ability to Open what they attach.

I am able to do this by using the SHELL function, where I am first checking
the File Extension, example if its FileName.xls, I check for the XLS & then
use the SHELL Function to Open Excel & that file. Again this works fine.

However, becuase there are so many File Types & programs to open them with,
I was wondering like in Wondows when u double click on a file Windows
automatically knows what type of file it is & opens it in its appropriate
program, & if for some reason it is not known then u have the option to
chosse form a list to open with.

I was wondering if the same can be done using VBA code, so matter what type
the file is it will open its appropriate program, without me having to put
logic for every type.

Any help would be greatly appreciated.

Thank you,
Jeff
 
Assuming you have the path to whatever file you want to open, try:

Application.FollowHyperlink (strFilePath)

TomU
 
Him Tom,

Thank you this was helpful.

With this, if the file type is unknown it generates an Error, # 490. Which
is ok as I can trap it. However I wanted to know if there is a way just like
in Windows to then display that Msgbox to have a user select from a list what
to try & open the file with. Do u know of any code to open that box perhaps
some API call ?

Thank you,
Jeff
 
Jeff said:
Him Tom,

Thank you this was helpful.

With this, if the file type is unknown it generates an Error, # 490.
Which is ok as I can trap it. However I wanted to know if there is a
way just like in Windows to then display that Msgbox to have a user
select from a list what to try & open the file with. Do u know of
any code to open that box perhaps some API call ?

The fHandleFile function posted here on the Access Web does just that:

http://www.mvps.org/access/api/api0018.htm
 
Back
Top