To that purpose I have started the following code, to look through the folder, and its subfolders:
Expand|Select|Wrap|Line Numbers
- Public Sub CollectInfo()
- On Error GoTo err_Handler
- Dim t As Date
- t = Now()
- Dim fs As New FileSystemObject
- Dim myFolder As Folder
- Set myFolder = fs.GetFolder("G:\TestFiles")
- Dim rsFiles As DAO.Recordset
- Set rsFiles = CurrentDb.OpenRecordset("tbl_Files")
- Dim oFolder As Folder
- Dim oFile As File
- For Each oFolder In myFolder.SubFolders
- For Each oFile In oFolder.Files
- Dim s As String
- s = oFile.Name & oFile.Path
- 'rsFiles.AddNew
- ' rsFiles!tx_FileName = oFile.Name
- ' rsFiles!tx_FilePath = oFile.Path
- 'rsFiles.Update
- Next oFile
- Next oFolder
- MsgBox "Procedure completed in: " & Second(Now() - t)
- exitSub:
- Set fs = Nothing
- Set oFile = Nothing
- Set oFolder = Nothing
- Set myFolder = Nothing
- Exit Sub
- err_Handler:
- MsgBox Err.Number & Err.Description
- Resume exitSub
- End Sub
It takes the current program 41 seconds to collection information on 270 files in roughly 20 subfolders where the main folder is placed on a network drive.
I get the impression that the filesystemobject is calling the fileserver for the information alot of times, and was wondering if there was any way to get the information needed in a batch processing sort of way to speed it up.
Other speedup suggestions are appreciated as well!