Option
Explicit
Private
Sub
SearchInFolder(
ByVal
Folderspec
As
String
,
ByVal
Zielordner
As
String
)
Dim
StTyp
As
String
Dim
FSO
As
Object
Dim
FI
As
Object
Dim
Anfangderdatei
As
String
Set
FSO = CreateObject(
"Scripting.Filesystemobject"
)
If
Not
FSO.FolderExists(Folderspec)
Then
MsgBox Folderspec &
" ist nicht vorhanden."
Set
FSO =
Nothing
Exit
Sub
End
If
StTyp =
"pdf"
Anfangderdatei =
"*"
& Format(
Date
,
"yyyy_ddmm"
) &
"*"
For
Each
FI
In
FSO.GetFolder(Folderspec).Files
If
UCase(FSO.GetExtensionName(FI)) = UCase(StTyp)
Then
If
UCase(FSO.GetFileName(FI))
Like
UCase(Anfangderdatei)
Then
FSO.MoveFile FI, Zielordner & "\"
End
If
End
If
Next
Set
FSO =
Nothing
End
Sub
Sub
Verschieben()
Call
SearchInFolder(
"H:\Test"
& Format(
Date
,
"yyyy_ddmm"
),
"H:\Test 2"
)
End
Sub