Wordle: 1

Wednesday 29 April 2015

Folders directory Scripting.FileSystemObject Method


Sub TestListFolders()
   
    Application.ScreenUpdating = False
   
     'create a new workbook for the folder list
   
     'commented out by dr
     'Workbooks.Add
   
     'line added by dr to clear old data
    Cells.Delete
   
     ' add headers
    With Range("A1")
        .Formula = "Folder contents:"
        .Font.Bold = True
        .Font.Size = 12
    End With
   
    Range("A3").Formula = "Folder Path:"
    Range("B3").Formula = "Folder Name:"
    Range("C3").Formula = "Size:"
    Range("D3").Formula = "Subfolders:"
    Range("E3").Formula = "Files:"
    Range("F3").Formula = "Short Name:"
    Range("G3").Formula = "Short Path:"
    Range("A3:G3").Font.Bold = True
   
     'ENTER START FOLDER HERE
     ' and include subfolders (true/false)
    ListFolders "C:\Users\MAA\Desktop\Access to Excel\", True
   
    Application.ScreenUpdating = True
   
End Sub