By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,225 Members | 1,434 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,225 IT Pros & Developers. It's quick & easy.

Open a file with file name from listbox

P: 47
click on name, and open with windows explorer.

I tried using shell
(Code)
Shell "explorer.exe " & sPath & lstYellow.Value, vbNormalFocus
(/code)

sPath is a variable set earlier and is ok, but I need to get the file name out of lstYellow, and value is not a good property. I have tried selected, listindes and others, but I think I just need some help in formatting, as the code is not finding the file at all.

I had help in etting this up,
I am not even sure how the shell line is supposed to look for this.
but something like this
Shell "explorer.ext" & "c:\App\Yellow|" & "012345.bmp", vbNormalFocus
(I am thinking the spacing must be very important, and I am sure the file is there) The file name does not show quotes in the list box.
Any help will be appreciated.
Thanks
Ken
Feb 8 '08 #1
Share this Question
Share on Google+
3 Replies


ADezii
Expert 5K+
P: 8,679
click on name, and open with windows explorer.

I tried using shell
(Code)
Shell "explorer.exe " & sPath & lstYellow.Value, vbNormalFocus
(/code)

sPath is a variable set earlier and is ok, but I need to get the file name out of lstYellow, and value is not a good property. I have tried selected, listindes and others, but I think I just need some help in formatting, as the code is not finding the file at all.

I had help in etting this up,
I am not even sure how the shell line is supposed to look for this.
but something like this
Shell "explorer.ext" & "c:\App\Yellow|" & "012345.bmp", vbNormalFocus
(I am thinking the spacing must be very important, and I am sure the file is there) The file name does not show quotes in the list box.
Any help will be appreciated.
Thanks
Ken
The Shell() Function is used primarily to Run an executable File, but strangely enough can be used to Open other File Extensions when used in the manner in which you indicate. The code snippet below should point you in the right direction:
Expand|Select|Wrap|Line Numbers
  1. Dim retVal As Variant, sPath As String
  2.  
  3. sPath = "C:\App\Yellow\"
  4.  
  5. 'Where Me![lstYellow] = 012345.bmp
  6. retVal = Shell("explorer.exe " & sPath & Me![lstYellow], vbNormalFocus)
Feb 8 '08 #2

P: 47
ADzeii,
Thank you very much. I appreciate you taking the time .
Ken
Feb 8 '08 #3

ADezii
Expert 5K+
P: 8,679
ADzeii,
Thank you very much. I appreciate you taking the time .
Ken
You are quite welcome.
Feb 8 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.