AW: Explorer-Suchergebnis in Excledatei hinein
02.06.2015 09:26:01
Nepumuk
Hallo,
ein einfaches Beispiel wie du nach Dateien suchen kannst und die Pfade in einer Tabelle ausgegeben werden.
Option Explicit
Public Sub Suchen()
Const ROOT_PATH As String = "D:\Eigene Dateien\" ' ***** Anpassen *****
Dim astrFolders() As String, strFile As String
Dim ialngIndex As Long, lngRow As Long
lngRow = 1
astrFolders = GetFolders(ROOT_PATH)
For ialngIndex = LBound(astrFolders) To UBound(astrFolders)
strFile = Dir$(astrFolders(ialngIndex) & "*.dft")
Do Until strFile = vbNullString
lngRow = lngRow + 1
Cells(lngRow, 1) = astrFolders(ialngIndex) & strFile
strFile = Dir$
Loop
Next
End Sub
Private Function GetFolders(ByVal pvstrPath As String) As String()
Dim astrFolders() As String
Dim strFolder As String, strPath As String
Dim ialngIndex1 As Long, ialngIndex2 As Long
strPath = pvstrPath
Do
strFolder = Dir$(strPath & "*", vbDirectory)
Do Until strFolder = vbNullString
If strFolder <> "." And strFolder <> ".." Then
If GetAttr(strPath & strFolder) And vbDirectory Then
Redim Preserve astrFolders(0 To ialngIndex1)
astrFolders(ialngIndex1) = strPath & strFolder & "\"
ialngIndex1 = ialngIndex1 + 1
End If
End If
strFolder = Dir$
Loop
If ialngIndex1 = ialngIndex2 Then Exit Do
strPath = astrFolders(ialngIndex2)
ialngIndex2 = ialngIndex2 + 1
Loop
GetFolders = astrFolders
End Function
Welche Informationen brauchst du zusätzlich in deiner Tabelle außer Autor und Speicherdatum?
Gruß
Nepumuk