Open a file with file name from listbox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • akirekab
    New Member
    • Oct 2006
    • 47

    #1

    Open a file with file name from listbox

    click on name, and open with windows explorer.

    I tried using shell
    (Code)
    Shell "explorer.e xe " & 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.e xt" & "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
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by akirekab
    click on name, and open with windows explorer.

    I tried using shell
    (Code)
    Shell "explorer.e xe " & 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.e xt" & "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:
    [CODE=vb]
    Dim retVal As Variant, sPath As String

    sPath = "C:\App\Yellow\ "

    'Where Me![lstYellow] = 012345.bmp
    retVal = Shell("explorer .exe " & sPath & Me![lstYellow], vbNormalFocus)[/CODE]

    Comment

    • akirekab
      New Member
      • Oct 2006
      • 47

      #3
      ADzeii,
      Thank you very much. I appreciate you taking the time .
      Ken

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        Originally posted by akirekab
        ADzeii,
        Thank you very much. I appreciate you taking the time .
        Ken
        You are quite welcome.

        Comment

        Working...