If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Visual Basic > get directrory size value pated into excel

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-30-10, 12:34
kato01 kato01 is offline
Registered User
 
Join Date: Nov 2004
Posts: 17
get directrory size value pated into excel

Hello,

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
Next

'Recurse through all of the folders
For Each objNewFolder In objCurrentFolder.subFolders
CheckFolder objNewFolder
Next
My_Results = FolderSize
End Sub
Reply With Quote
  #2 (permalink)  
Old 12-30-10, 13:14
Teddy Teddy is offline
Purveyor of Discontent
 
Join Date: Mar 2003
Location: The Bottom of The Barrel
Posts: 6,075
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? ***
Reply With Quote
Reply

Tags
directory size, excel

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On