Option
Explicit
Sub
Test()
Dim
strPath
As
String
Dim
strFile
As
String
strPath =
"X:\Verzeichnis\Unterverzeichnis"
If
Right$(strPath, 1) <> "\" _
Then
strPath = strPath & "\"
strFile = Dir$(strPath)
Do
While
strFile <>
""
If
InStr(strFile,
"337"
)
And
GetExtension(strFile) =
"pdf"
Then
Debug.Print
"PDF:"
, strFile
ElseIf
InStr(strFile,
"Foto"
)
And
GetExtension(strFile) =
"jpg"
Then
Debug.Print
"FOTO:"
, strFile
ElseIf
GetExtension(strFile)
Like
"xls*"
Then
Debug.Print
"EXCEL:"
, strFile
End
If
strFile = Dir$()
Loop
End
Sub
Function
GetExtension(File
As
String
)
As
String
Dim
i
As
Long
i = InStrRev(File,
"."
)
If
i
Then
GetExtension = Right$(File, Len(File) - i)
End
Function