| VBA-Beispiel 115 | |
|
|
|
per VBA Ordnergröße ermitteln |
|
| Die Funktion ermittelt die Größe eines Ordners in Bytes. | |
|
Public Sub Aufruf() Dim strOrdner As String strOrdner = ThisWorkbook.Path MsgBox Format(Ordnergroesse(strOrdner), "#,##") & " Bytes" _ , vbInformation, strOrdner End Sub Private Function Ordnergroesse(ByVal strPfad As String) As Long Dim objFSO As Object Dim objOrdner As Object On Error GoTo Fehler Set objFSO = CreateObject("Scripting.FileSystemObject") Set objOrdner = objFSO.GetFolder(strPfad) Ordnergroesse = objOrdner.Size / 1000 'Ordnergröße Exit Function Fehler: MsgBox "FehlerNr.: " & Err.Number & _ vbNewLine & vbNewLine & _ "Beschreibung: " & Err.Description, _ vbCritical, "Fehler:" End End Function |
|
|
Download: vba115.zip |
|
|
relevante Links: |
|
| |