if a particular file exists, and False if not : FileSearch « File Path « VBA / Excel / Access / Word






if a particular file exists, and False if not

 
Function FileExists(fname) As Boolean
    With Application.FileSearch
        .NewSearch
        .Filename = fname
        .Execute
        If .FoundFiles.Count = 0 Then _
          FileExists = False _
          Else FileExists = True
    End With
End Function

 








Related examples in the same category

1.The FileSearch Object
2.PropertyTests
3.The FoundFiles Collection Object
4.searches the My Documents directory and its subdirectories for all XLS files that contain the text budget.
5.Find a file
6.Find a file with wildcard character
7.File files with Application.FileSearch
8.Use Application.FileSearch to find files