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

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
 
C

Chuck

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top