ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Filename from the result of a Filesearch (https://www.excelbanter.com/excel-programming/349470-filename-result-filesearch.html)

pauloreiss[_2_]

Filename from the result of a Filesearch
 

When I request Application.FileSearch.filename i get the name of th
file i searched. In my case "*.xls".
I would like to get the name of the file that the search found.
The Application.FileSearch.foundfiles gives me the full path. How do
get only the name of the file??

--
pauloreis
-----------------------------------------------------------------------
pauloreiss's Profile: http://www.excelforum.com/member.php...fo&userid=2982
View this thread: http://www.excelforum.com/showthread.php?threadid=49790


Bernie Deitrick

Filename from the result of a Filesearch
 
Paulo,

With Application.FileSearch
..NewSearch
..LookIn = "C:\Documents and Settings"
..Filename = "*.xls"
If .Execute 0 Then
For i = 1 To .FoundFiles.Count
MsgBox Mid(.FoundFiles(i), InStrRev(.FoundFiles(i), "\") + 1, _
Len(.FoundFiles(i)))
Next i
End If
End With

HTH,
Bernie
MS Excel MVP


"pauloreiss" wrote in message
...

When I request Application.FileSearch.filename i get the name of the
file i searched. In my case "*.xls".
I would like to get the name of the file that the search found.
The Application.FileSearch.foundfiles gives me the full path. How do i
get only the name of the file???


--
pauloreiss
------------------------------------------------------------------------
pauloreiss's Profile: http://www.excelforum.com/member.php...o&userid=29820
View this thread: http://www.excelforum.com/showthread...hreadid=497901





All times are GMT +1. The time now is 10:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com