Option
Explicit
Dim
sPfad
As
String
, temp
As
String
Sub
myDir_auflisten()
Dim
Opt
As
Variant
, n
As
Integer
Dim
Dtyp
As
String
, z
As
Integer
On
Error
GoTo
Fehler
Range(
"C2:C4"
) = Empty
Range(
"A5:E1000"
).Clear
Dtyp = Range(
"F2"
).Value
If
Dtyp =
""
Then
Dtyp =
"*.*"
sPfad = Range(
"C1"
).Value
temp = Dir(sPfad & "\" & Dtyp)
If
InStr(Dtyp,
"."
) = 0
Then
MsgBox _
"Ungültiger Dateitup, Punkt fehlt"
:
Exit
Sub
Do
While
temp <>
""
z = z + 1: n = n + 1
Cells(z + 4, 2) = z
Cells(z + 4, 3) = temp
Cells(z + 4, 4) = FileLen(sPfad & "\" & temp)
Cells(z + 4, 5) = FileDateTime(sPfad & "\" & temp)
temp = Dir
Loop
If
n > 0
Then
Range(
"A5"
) =
" "
& n &
" Dateien"
If
n = Empty
Then
[c2] =
"Ordner No Find / Leer, oder Dateityp ungültig"
Range(
"A2"
).Value = Now
Range(
"B5"
, [b5].
End
(xlDown)).HorizontalAlignment = xlCenter
Exit
Sub
Fehler: MsgBox
"unerwarteter Fehler - Abbruch"
End
Sub
Sub
myDir_Auswäahlen()
Dim
Opt
As
Variant
, n
As
Integer
Dim
Dtyp
As
String
, z
As
Integer
With
Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect =
False
If
.Show = 0
Then
Exit
Sub
sPfad = .SelectedItems(1)
End
With
On
Error
GoTo
Fehler
Range(
"C2:C4"
) = Empty
Range(
"A5:E1000"
).Clear
Range(
"C3"
) = sPfad
Dtyp = Range(
"F2"
).Value
If
Dtyp =
""
Then
Dtyp =
"*.*"
temp = Dir(sPfad & "\" & Dtyp)
If
InStr(Dtyp,
"."
) = 0
Then
MsgBox _
"Ungültiger Dateitup, Punkt fehlt"
:
Exit
Sub
Do
While
temp <>
""
z = z + 1: n = n + 1
Cells(z + 4, 2) = z
Cells(z + 4, 3) = temp
Cells(z + 4, 4) = FileLen(sPfad & "\" & temp)
Cells(z + 4, 5) = FileDateTime(sPfad & "\" & temp)
temp = Dir
Loop
If
n > 0
Then
Range(
"A5"
) =
" "
& n &
" Dateien"
If
n = Empty
Then
[c2] =
"Ordner No Find / Leer, oder Dateityp ungültig"
Range(
"A2"
).Value = Now
Range(
"B5"
, [b5].
End
(xlDown)).HorizontalAlignment = xlCenter
Exit
Sub
Fehler: MsgBox
"unerwarteter Fehler - Abbruch"
End
Sub