Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub makeDir(path As String)
- Dim ps As String: ps = Application.PathSeparator
- If Right(path, 1) = ps Then path = Left(path, Len(path) - 1)
- Dim parent As String: parent = Left(path, InStrRev(path, ps))
- If Dir(parent, vbDirectory) = "" Then makeDir parent
- MkDir path
- End Sub
- 'Return the path so you can use `path = makeDir(newpath)
- Function makeDir(path As String) As String
- Dim hasPS As Boolean
- Dim ps As String: ps = Application.PathSeparator
- If Dir(path, vbDirectory) = "" Then
- If Right(path, 1) = ps Then
- path = Left(path, Len(path) - 1)
- hasPS = True
- End If
- makeDir Left(path, InStrRev(path, ps))
- MkDir path
- End If
- If hasPS Then
- makeDir = path & ps
- Else
- makeDir = path
- End If
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement