leider komme ich alleine bei der Analyse des Fehlers in dem verwendeten Makro zum Listen von Dateien aus Ordner und zugehöriger Unterordner nicht weiter.
Leider setzt das hier gefundene Makro leider nur die Fehleinträge:
"!Fehler beim Dateien lesen!"
ab, siehe Anhang. Vielleicht kann mir hier jemand weiterhelfen, ich sehe/finde den Fehler leider nicht selbst.
Danke im Voraus für eure Bemühungen.
Grüße
Pit
Hier die Analyse im VB Editor:
https://www.herber.de/bbs/user/166841.htm
Dim FSO, FO, FU, F
Dim lRow As Long
Dim icol As Integer
Sub Dateien_in_Verzeichnissen_Listen()
Dim varAuswahl As Variant, strDir As String
varAuswahl = Application.GetOpenFilename(Title:="Bitte Ordner wählen und dann abbrechen")
strDir = VBA.CurDir
If MsgBox(strDir & " auslesen?", vbOKCancel) = vbCancel Then Exit Sub
Application.ScreenUpdating = False
Set FSO = CreateObject("Scripting.FileSystemObject")
ActiveSheet.UsedRange.Clear
icol = 0
lRow = 0
lRow = lRow + 1
icol = icol + 1
If Right(strDir, 1) > "\" Then strDir = strDir & "\"
Cells(lRow, icol) = strDir 'gewählten Ordner eintragen
Call aDateienListen(strPath:=strDir)
GetSubFolders strDir
Application.ScreenUpdating = True
MsgBox "Fertig"
End Sub
Function GetSubFolders(Pfad)
Set FO = FSO.GetFolder(Pfad)
Set FU = FO.SubFolders
On Error Resume Next
For Each F In FU
lRow = lRow + 1
icol = icol + 1
If Right(F.Path, 1) > "\" Then F.Path = F.Path & "\"
Cells(lRow, icol) = F.Name ' 'Ordnername
Cells(lRow, icol).Interior.ColorIndex = 6 'gelb einfärben
If IsEmpty(F) Then 'Probleme beim Zugriff auf Unterordner
Cells(lRow, icol) = "!keine Leseberechtigung!"
icol = icol - 1
Else
If aDateienListen(strPath:=F.Path) = False Then
Cells(lRow, icol) = "!Problem beim Dateien lesen!"
End If
End If
If Right(F.Path, 1) > "\" Then F.Path = F.Path & "\"
GetSubFolders F.Path
Next
icol = icol - 1
End Function
Private Function aDateienListen(strPath As String) As Boolean
Dim objFile
On Error GoTo FEHLER
aDateienListen = True
'If Right(strPath, 1) > "\" Then strPath = strPath & "\"
With Application.FileSearch
.NewSearch
.LookIn = strPath
.SearchSubFolders = False
.FileType = msoFileTypeAllFiles
If .Execute() > 0 Then
For Each objFile In .FoundFiles
lRow = lRow + 1
Cells(lRow, icol) = Replace(objFile, IIf(Right(strPath, 1) = "\", strPath, _
strPath & "\"), "") ' ###
'hyperlink einfügen
ActiveSheet.Hyperlinks.Add Anchor:=Cells(lRow, icol), Address:=objFile
Next
End If
End With
Exit Function
FEHLER:
'Fehler beim Auslesen des Ordners
aDateienListen = False
End Function