Use VBA to open a file with it's associated application

  • Thread starter Thread starter Chuck
  • Start date Start date
C

Chuck

Hi

I'm having the hardest time trying to figure this one out.

I simply want to use VBA code to open a file (in this case a JPG image)
located on the local computer. I want to file to open in whatever
application is associated with it (PhotoEditor, Image Viewer, or whatever).
The path to the file is contained in one of my access tables and I want the
code to be invoked when I click a button on a form.

I tried several approaches but I can't get any of them to work. I assume
that I have to create an object with CreateObject but from what I can tell,
I have to specify the class like "Word.Application" or "Excel.Worksheet"



Any help would be appreciated.

Thanks
 
Thanks. Much appreciated.


Graham Mandeno said:
Hi Chuck

You use the system's ShellExecute function, and it behaves just as if the
user had double-clicked on the file in Explorer. Simply copy and paste
the code from here: http://www.mvps.org/access/api/api0018.htm
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Chuck said:
Hi

I'm having the hardest time trying to figure this one out.

I simply want to use VBA code to open a file (in this case a JPG image)
located on the local computer. I want to file to open in whatever
application is associated with it (PhotoEditor, Image Viewer, or
whatever). The path to the file is contained in one of my access tables
and I want the code to be invoked when I click a button on a form.

I tried several approaches but I can't get any of them to work. I assume
that I have to create an object with CreateObject but from what I can
tell, I have to specify the class like "Word.Application" or
"Excel.Worksheet"



Any help would be appreciated.

Thanks
 
Back
Top