I have an unbound ListBox with 1 column that is populated OnLoad with a list of files in a folder. The user can click on any of the lines in the list box which opens the related file. This works as the entire filepath is what is stored in the ListBox and passed to Windows Shell.
I would like the listbox to display only the filenames, but still be able to follow a full link on clicking. My thoughts were to change the ListBox to 2 column and have the 1st column as the bound column but hidden and have a second column that the user actually sees that displays only the filename.
The code below works nicely to pull the filename from the filepath for an individual file. Is there a way to apply this to all the "rows" in the list so it populates the 2nd column with the filenames from the first?
Thanks in advance.
I would like the listbox to display only the filenames, but still be able to follow a full link on clicking. My thoughts were to change the ListBox to 2 column and have the 1st column as the bound column but hidden and have a second column that the user actually sees that displays only the filename.
The code below works nicely to pull the filename from the filepath for an individual file. Is there a way to apply this to all the "rows" in the list so it populates the 2nd column with the filenames from the first?
Thanks in advance.
Code:
Dim sPath As String
Dim sFile As String
sPath = FileList.Column(0)
sFile = Right(sPath, Len(sPath) - InStrRev(sPath, "\"))
MsgBox sFile