Anzeige
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Anzeige
Inhaltsverzeichnis

vba

Forumthread: vba

vba
19.09.2021 02:13:00
uwehinku
Hallo,
wie kann ich mir über MSGBOX das aktive Verzeichnis mit Unterverzeichnissen anzeigen lassen?
mfg
uwehinku
Anzeige

2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: vba
19.09.2021 11:38:18
Hajo_Zi
Du meinst den Ordner der aktuellen Datei?
MsgBox ThisWorkbook.Path
Gruß Hajo
AW: vba
19.09.2021 16:29:53
Nepumuk
Hallo Uwe,
teste mal:

Public Sub Test()
MsgBox Join(GetFolders(ThisWorkbook.Path & "\"), vbLf)
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
ReDim Preserve astrFolders(ialngIndex1)
astrFolders(ialngIndex1) = pvstrPath
ialngIndex1 = 1
ialngIndex2 = 1
strPath = pvstrPath
Do
strFolder = Dir$(PathName:=strPath & "*", Attributes:=vbDirectory)
Do Until strFolder = vbNullString
If strFolder  "." And strFolder  ".." Then
If GetAttr(PathName:=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
Bedenke, es gibt eine Längenbegrenzung für Text in einer MsgBox.
Gruß
Nepumuk
Anzeige
Anzeige
Anzeige
Live-Forum - Die aktuellen Beiträge
Datum
Titel
14.05.2026 13:31:09
14.05.2026 09:50:42
13.05.2026 19:14:18