16 replies
by beerman97
by beerman97
by beerman97
by beerman97
by dklippert
Here's a cobble from the VB help file. It shows the size of a selected file, but you can add code to search for other folders and present the data as you wish. The important part is indicated at the end of the code.
(This app sometimes throws in extra spaces, so take that into account)
Sub FolderList()
'
' Macro to show folder size.
Dim x, fs
Dim I As Integer
Dim y As Integer
Dim Folder, MyName, TotalFiles, Response, PrintResponse, AgainResponse
On Error Resume Next
Folder:
' Prompt the user for the folder to list.
x = InputBox("What folder do you want to list?" & Chr$(13) & Chr$(13) _
& "For example: C:\My Documents")
If x = "" Or x = " " Then
Response = MsgBox("Either you did not type a folder name correctly" _
& Chr$(13) & "or you clicked Cancel. Do you want to quit?" _
& Chr$(13) & Chr$(13) & _
"If you want to type a folder name, click No." & Chr$(13) & _
"If you want to quit, click Yes.", vbYesNo)
If Response = "6" Then
End
Else
GoTo Folder
End If
Else
' Test if folder exists.
Set Folder = CreateObject("Scripting.filesystemobject")
If Folder.folderexists(x) = "True" Then
Else
MsgBox "The folder does not exist. Please try again."
GoTo Folder
End If
End If
' SEE BELOW FOR SIZE CODE
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(x)
s = UCase(f.Name) & " uses " & f.Size & " bytes."
MsgBox s, 0, "Folder Size Info"
End:
End Sub
by beerman97
by beerman97
by beerman97
by beerman97
by beerman97
by chris hirst
by beerman97
by dklippert
This code should do what you want:
http://www.klippert.com/excel/code.htm
(there are no spaces in the URL)
by beerman97
by beerman97
This discussion is closed to new replies.
Trending Software posts
Sort by Trending