View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Muk Muk is offline
external usenet poster
 
Posts: 10
Default Check File name for its existance in a folder

Martin I do not know why this is not working.

Can you guess why?

"Martin Fishlock" wrote:

Muk

You can use the following, it only searchs for one condition at a time so
you need to devise some logic to keep multiple condition results.
See the line with <<<< in it to change the condition.

Sub fso()
Const msoFileTypeExcelWorkbooks = 4

Dim fs As Object 'FileSearch
Dim ff
Dim lRow As Long

Set fs = Application.FileSearch
fs.LookIn = "C:\Documents and Settings\admin\My Documents"
fs.SearchSubFolders = True
fs.TextOrProperty = "Files" '<<< text to find wilds ok
fs.FileType = msoFileTypeExcelWorkbooks
fs.Execute

For Each ff In fs.FoundFiles
lRow = lRow + 1
ActiveSheet.Cells(lRow, 1) = ff
Next

End Sub

--
Hope this helps
Martin Fishlock
Please do not forget to rate this reply.


"Muk" wrote:

Hi
I want to check for some particular files (Containing some particular words
like time sheets or April/May 2006€¦.) are already there in a folder or not.
Can I check I mean search whether the particular file is there in folder or
not?

Is this possible with a macro code?

Any help on this is much appreciated
Regards,
Muk