Open External File

G

Guest

Thanks for taking the time to read my question.

I have a list of files and their file path (Location) in a list box. I
would like to be able to have the user select an item in the list then click
a button to open that file. I don't want to make the items in the list box
hyperlinks as I use the list box for other things as well.

I tried using the Shell function but it didn't work.

The value of the list box when an item is selected is something like:

"C:\Documents and Settings\User1\My Documents\Test.csv"

So in my sub I have:

Dim RetVal

RetVal = Shell(Me.lst_FileFolder,1)

but that just gives me an error. I'd like them to be able to click the
button and the file opens in what ever program the file is associated to.

Thanks again for your help,

Brad
 
D

Douglas J Steele

The Shell command is intended for executables. You'd need to pass the path
to Excel or Notepad or whatever you want to open the file in in addition to
the file name.

Alternatively, you can use the ShellExecute API to open the file in its
registered application. See http://www.mvps.org/access/api/api0018.htm at
"The Access Web" for a complete example.
 

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

Similar Threads


Top