Gruppe
Datei
Problem
Über den MkDir-Befehl kann ich ein Unterverzeichnis anlegen. Wie lege ich aber einen kompletten Verzeichnisbaum an? Das komplette Verzeichnis soll über ein Inputbox angegeben werden.
StandardModule: basMain
Sub MultiMkDir()
Dim iCounter
Dim sPath As String, sTxt As String
sPath = InputBox("Bitte Pfad angeben:", , "c:\mypath")
If Right(sPath, 1) <> "\" Then sPath = sPath & "\"
iCounter = 4
Do While InStr(iCounter, sPath, "\") > 0
sTxt = Left(sPath, InStr(iCounter, sPath, "\") - 1)
iCounter = InStr(iCounter, sPath, "\") + 1
On Error GoTo ErrorHandler
MkDir sTxt
Loop
Exit Sub
ErrorHandler:
If Err = 75 Then
Beep
MsgBox "Verzeichnis besteht schon!"
End If
End Sub