total descendants::0 total children::0 |
sub tst RecursiveDir colFiles, "\BLAIN", fileName, True end sub Public Function RecursiveDir(colFiles As Collection, _ strFolder As String, _ strFileSpec As String, _ bIncludeSubfolders As Boolean) Dim strTemp As String Dim colFolders As New Collection Dim vFolderName As Variant 'pridavanie suborov kore splnili kriteria do kolekcie strFolder = TrailingSlash(strFolder) strTemp = Dir(strFolder & strFileSpec) Do While strTemp <> vbNullString colFiles.Add strFolder & strTemp strTemp = Dir Loop If bIncludeSubfolders Then 'naplnanie kolekcie zloziek a podzloziek strTemp = Dir(strFolder, vbDirectory) Do While strTemp <> vbNullString If (strTemp <> ".") And (strTemp <> "..") Then If (GetAttr(strFolder & strTemp) And vbDirectory) <> 0 Then colFolders.Add strTemp End If End If strTemp = Dir Loop 'volanie tejto funkcie na kazdu zlozku a podzlozku ktora je novsia ako aktualny rok - 1 For Each vFolderName In colFolders If Year(FileDateTime(strFolder & vFolderName)) > Year(Date) - 1 Then Call RecursiveDir(colFiles, strFolder & vFolderName, strFileSpec, True) End If Next vFolderName End If End Function Public Function TrailingSlash(strFolder As String) As String If Len(strFolder) > 0 Then If Right(strFolder, 1) = "" Then TrailingSlash = strFolder Else TrailingSlash = strFolder & "" End If End If End Function |
| |||||||||||||||||||||||