Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
FileSearch - help
Hello to all
I have one problem which is probably peace of cake for you. I have code below which in "list1" display list of all files from path "TextBox4" and which begin with "TextBox3". Let say that TextBox4 value is c:\test\ and TextBox5 value is 123456789. When program run, in "List1" I get displayed file paths, for instance : c:\test\123456789_1.jpg c:\test\123456789_2.jpg c:\test\123456789_3.jpg c:\test\123456789_4.jpg Problem is that I don't want whole path, I want only file names. 123456789_1.jpg 123456789_2.jpg 123456789_3.jpg 123456789_4.jpg I guess that problem is stupid but I can't find solution. Thanks in advance ! Code ---------------------------------------------------------------------------- ------------- Private Sub CommandButton7_Click() Dim Path As String Dim fsoFileSearch As FileSearch Dim varFile As Variant list1.Clear List2.Clear Path = (Me.TextBox4.Text) Set fsoFileSearch = Application.FileSearch On Error Resume Next With fsoFileSearch .NewSearch .LookIn = "Path" .Filename = (Me.TextBox4.Text) & "*" & ".jpg" .SearchSubFolders = False If .Execute(msoSortByFileName, msoSortOrderAscending, True) 0 Then For Each varFile In .FoundFiles Me.list1.AddItem varFile Next varFile End If End With End Sub ---------------------------------------------------------------------------- --------------------------- |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
FileSearch in a combo box | Excel Discussion (Misc queries) | |||
Filesearch in VB6 | Excel Programming | |||
FileSearch | Excel Programming | |||
FileSearch using VBA | Excel Programming | |||
.FileSearch | Excel Programming |