[Solved] VBA : list of files

  • I am currently using this code to bring up a list of Jpg files in a list box.

    With Application.FileSearch

    .LookIn = "Directory Path here"
    .Filename = "*.jpg" 'file extension
    .SearchSubFolders = False
    For i = 1 To .FoundFiles.Count
    imageform1.ListBox1.AddItem .FoundFiles(i)
    Next i
    End With

    Now this shows the entire file path in the list box. Is there a way to just have the file name appear in the listbox?

    Thanks in advance

  • Hi Brister,

    You can use the replace function to get rid of the unneeded path info.

    That should work but I haven't debugged. Best of luck.



  • Thanks you Andy and DNAgirl!!!

    That worked awsome Andy!! What is the breakdown of that line, I usually understand better when I know what each part did for furure reference.(other than the add item part)

  • Hi Brister,

    From the help file,



Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!