![]() Optional ByRef fo_result As String) As Collection Optional ByVal fo_subfolders As Boolean = False, _ The function looks as follows: Public Function Folders(Optional ByVal fo_spec As String = vbNullString, _ The collection then may be used for any purpose just by looping through the collection. I became motivated to provide for myself with a kind of universal function which returns a collection of folder objects plus optionally all sub-folders all in ascending order. Under Tools, set a reference to 'Microsoft Scripting Runtime'. ' use file methods (not proper in this example)įor Each SubFolder In SourceFolder.SubFolders ![]() Set SourceFolder = FSO.GetFolder(SourceFolderName)Ĭells(r, 1).Formula = FileItem.Path & FileItem.NameĬells(r, 2).Formula = (FileItem.Size / 1048576)Ĭells(r, 2).Value = Format(Cells(r, 2).Value, "#.#") & " MB"Ĭells(r, 4).Formula = FileItem.DateCreatedĬells(r, 5).Formula = FileItem.DateLastAccessedĬells(r, 6).Formula = FileItem.DateLastModified ' lists information about the files in SourceFolderĭim SourceFolder As Scripting.Folder, SubFolder As Scripting.Folder ![]() Sub ListFilesInFolder(SourceFolderName As String, IncludeSubfolders As Boolean) With ActiveWorkbook.Worksheets("ListOfFiles").Sort "B4:B" & Lastrow), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _ Range(Selection, Selection.End(xlDown)).SelectĪctiveWorkbook.Worksheets("ListOfFiles").ĪctiveWorkbook.Worksheets("ListOfFiles"). Key:=Range( _ Range(Selection, Selection.End(xlToRight)).Select ListFilesInFolder Worksheets("ListOfFiles").Range("A1").Value, True ![]() Range("F3").Formula = "Date Last Modified:" Range("E3").Formula = "Date Last Accessed:" Workbooks.Add ' create a new workbook for the file list With Application.FileDialog(msoFileDialogFolderPicker) ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |