Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2004

    Unanswered: get directrory size value pated into excel


    I am tring to save some space on my harddrive.
    I have a list of directories in excel.
    The search results are listed in excel (say column A)
    Next (with excel report open), I need to:
    1. find out the size of each directory listed in every row of column A
    2. print that number (the directory size) in the coresponding rows of Column B

    I wrote a small VBA code (based on a VBscript I downloaded, however it does not work.
    The error message is:"Object required.."
    Please see below the code in the VBA editor in excel

    Sub connect()
    'Set oFolder = fso.GetFolder(objCurrentFolder)
    For i = 1 To 5025
    Cells(i, 10).Value = Cells(i, 2).Value + Cells(i, 1).Value
    rootfolder = Cells(i, 10).Value

    Call CheckFolder(fso.GetFolder(rootfolder), My_Results)

    Cells(i, 11).Value = My_Results
    Next i
    End Sub

    Sub CheckFolder(objCurrentFolder, My_Results)
    Set oFolder = fso.GetFolder(objCurrentFolder)
    For Each objFolder In objCurrentFolder.subFolders
    FolderSize = objFolder.Size
    Tmp = (FormatNumber(FolderSize, 0, , , 0) / 1024) / 1024
    'Wscript.Echo Tmp & " " & objFolder.Path
    'raise counter with 1 for a new row in excel
    icount = icount + 1

    'Recurse through all of the folders
    For Each objNewFolder In objCurrentFolder.subFolders
    CheckFolder objNewFolder
    My_Results = FolderSize
    End Sub

  2. #2
    Join Date
    Mar 2003
    The Bottom of The Barrel
    Provided Answers: 1
    Where did you set fso? On what line do you see an error?
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts