PDA

View Full Version : Add some .avi files in a ListBox



metev
12-02-2007, 01:35 PM
Hi guys ,

Do you know how to add some media files in a listbox. So I have some media files saved in a folder. Now I want to add them all in the UF. When I select one of them from the listbox, a hyperlink to the file in that folder should be made.

10x
metev

figment
12-04-2007, 10:55 AM
try this

Sub testing()
userform1.listbox1.List = list1(Path, "avi", True)
End Sub

Function list1(location As String, filetype As String, search_subfolder As Boolean)
Dim a As Long, b As Long
ReDim c(0 To 0) As String
a = 1
b = 0
With Application.FileSearch
.LookIn = location
.filetype = msoFileTypeAllFiles
.SearchSubFolders = search_subfolder
If (.Execute <> 0) Then
While a <= .FoundFiles.Count
c(b) = .FoundFiles.Item(a)
If LCase(Right(c(b), 3)) = filetype Then
b = b + 1
ReDim Preserve c(0 To b) As String
End If
a = a + 1
Wend
End If
End With
list1 = c
End Function