VBA, MS Access MS Access в примерах

FSO - Поиск файлов в папках и подпапках

По материалам: http://www.cyberforum.ru/vba/thread2335446.html

Private Sub Комманда1_Click()
 Dim FSO As Object
   Set FSO = CreateObject("Scripting.FileSystemObject")
   Search FSO.GetFolder("D:\")
End Sub
 
 Sub Search(Fold As Object)
 Dim SubFold As Object, Fil As Object
   Debug.Print Fold
   On Error GoTo ErrHandle
   For Each SubFold In Fold.SubFolders
     Search SubFold
   Next SubFold
   For Each Fil In Fold.Files
        Debug.Print Fil
   Next Fil
   Exit Sub
ErrHandle:
   MsgBox "Нет допуска к папке! """ & Fold.Path & """"
   Err.Clear
End Sub
Назад ToTop
L.E. 04.02.2024
Рейтинг@Mail.ru