Rudi GOUSSEY
New Member
- Joined
- Jan 8, 2004
- Messages
- 32
Does anybody knows the VBA-code which shows the total size of a directory (subdirectories included).
Thanks
Thanks
Sub FolderSize()
Dim fso As Object, fsoFolder As Object
Const strFolderName As String = "C:\My Documents"
Set fso = CreateObject("Scripting.FileSystemObject")
Set fsoFolder = fso.GetFolder(strFolderName)
MsgBox fsoFolder.Size & " bytes"
Set fsoFolder = Nothing
Set fso = Nothing
End Sub
If you just had c:\windows\windows.exe in one cell, could you have a formula that would return the file size, assuming of course that you have access to that directory?
I asked:Ok, so you have successfully answered your own question!
It doesn't seem as though this particular macro will do exactly that, so therefore I have proven it's impossible to return the size of a file via a UDF?If you just had c:\windows\windows.exe in one cell, could you have a formula that would return the file size, assuming of course that you have access to that directory?
Public Function FileSize(FileName As String)
Dim FSO As Object
Set FSO = CreateObject("scripting.filesystemobject")
Set file = FSO.Getfile(FileName)
FileSize = file.Size
Set FSO = Nothing
End Function