Neues Verzeichnis anlagen
sks
Gesendet: 26.02.19 09:23
Betreff: RE: Neues Verzeichnis anlagen


Regular

Beiträge: 69
2525
Ich verwende dafür folgende Funktion :

'Verschachtelte Verzeichnisse erstellen
Public Function MakePath(ByVal spath As String, Optional ByVal ShowMsg As Variant) As Boolean

Dim Antwort As Integer
Dim dummy As String

If IsMissing(ShowMsg) Then ShowMsg = False

Antwort = 0: Err = 0
dummy = ""
On Local Error Resume Next
While Len(spath) > 0 And Antwort = 0
If Left$(spath, 2) = "\\" Then
dummy = dummy + "\\"
spath = Mid$(spath, 3)
ElseIf Left$(spath, 1) = "\" Then
dummy = dummy + "\"
spath = Mid$(spath, 2)
ElseIf Mid$(spath, 2, 2) = ":\" Then
dummy = dummy + Left$(spath, 3)
spath = Mid$(spath, 4)
End If
While Left$(spath, 1) <> "\" And Len(spath) > 0
dummy = dummy + Left$(spath, 1)
spath = Mid$(spath, 2)
Wend
Err = 0
MkDir dummy
If Err <> 75 And Err <> 0 Then
If ShowMsg Then
Antwort = MsgBox("Fehler beim Erstellen des Verzeichnisses!" + vbCrLf + 48, "Fehler")
Else
Antwort = 1
End If
End If
Wend
On Local Error GoTo 0

MakePath = (Antwort = 0)

End Function
Top of the page Bottom of the page