First, add the following to a module in your Master workbook: this will need tweeking but you will get the idea
This code was provided by shg
Function MakeDir(ByVal sDir As String) As Long
' Returns -1 if sDir already exists
' 1 if sDir is successfully created
' 0 if sDir cannot be created
Dim sPS As String
Dim astr() As String
Dim iLvl As Long
If Len(Dir(sDir, vbDirectory)) Then
MakeDir = -1
Else
sPS = Application.PathSeparator
If Right(sDir, 1) = sPS Then sDir = Left(sDir, Len(sDir) - 1)
astr = Split(sDir, sPS)
sDir = vbNullString
' MkDir will fail if sDir contains character codes 0-31
' or any of the characters ' < > : " / \ | ? *
' or if the drive does not exist,
' or if the user does not have permissions, so ...
On Error GoTo Oops
For iLvl = 0 To UBound(astr)
sDir = sDir & astr(iLvl) & sPS
If Len(Dir(sDir, vbDirectory)) = 0 Then MkDir sDir
Next iLvl
MakeDir = 1
End If
OuttaHere:
Exit Function
Oops:
Err.Clear
Resume OuttaHere
End Function
Bookmarks