LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
FileSearch in a combo box michaelberrier Excel Discussion (Misc queries) 0 June 16th 06 12:21 AM
Filesearch in VB6 Colin Charman Excel Programming 3 June 18th 04 04:18 PM
FileSearch Stephen[_6_] Excel Programming 8 June 12th 04 11:14 PM
FileSearch using VBA Mark[_31_] Excel Programming 2 December 24th 03 05:49 PM
.FileSearch Randall[_3_] Excel Programming 4 November 26th 03 01:48 AM


All times are GMT +1. The time now is 01:16 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"