View Single Post
  #9   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

Thanks Gary

This worked and solved my problem

Thank indeed
Regards,
Muk

"Gary Keramidas" wrote:

this will display a message box for all files with 2006 in the name of the
default folder.

add the path you want to check and change 2006 to something you want to
search for
fName = Dir("C:\MyFolder\*2006*.xls")


Option Explicit
Dim fname As String
Sub test()
fname = Dir("*2001*.xls") 'Do While fname < ""
MsgBox fname
fname = Dir()
Loop
End Sub


--


Gary


"Muk" wrote in message
...
Gary; I am sorry as I believe that I haven't explained my problem
correctly.
Your Code is working but really what I want is to find is files which
contain some particular contents of word in the Name.
Like "Timesheets" or "2006" or "January"
and to make a list of the same

Regards,
Muk

"Gary Keramidas" wrote:

from dave peterson


dim teststr as string
teststr = ""
on error resume next
teststr = dir("yourpath\yourfilenamehere")
on error goto 0

if teststr = "" then
'not found
else
'found
end if


--


Gary


"Muk" wrote in message
...
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