1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| Option Explicit
Dim path_start
Dim Myfso, result
Set Myfso = CreateObject("Scripting.FileSystemObject")
path_start = "c:\"
result = Find(path_start, InputBox("Entrez le nom du fichier à rechercher : "))
MsgBox result
Function Find (strPath, strFileName)
Dim MyDir, MyFile, MySubDir
Dim strResult
If strFileName = Empty Then Exit Function
strFileName = Ucase(strFileName)
Set MyDir = Myfso.GetFolder(strPath)
For Each MyFile In MyDir.Files
If Ucase(MyFile.Name) = strFileName Then strResult = strResult & strPath & "\" & MyFile.Name & vbCrLf
Next
For Each MySubDir In MyDir.SubFolders
strResult = strResult & Find(strPath & "\" & MySubDir.Name, strFileName)
Next
Find = strResult
End Function |
Partager