Jürgen Welz
jwelz at hotmail.com
Tue May 4 19:08:02 CDT 2004
Have I said before I hate the FS object...
Public Function fnCreateBasePath(strCreatePath As String) As Boolean
On Error GoTo ErrorHandler
Dim strPath As String
Dim lngPosition As Long
strCreatePath = Trim(strCreatePath)
If Right$(strCreatePath, 1) <> "\" Then strCreatePath = strCreatePath &
"\"
lngPosition = 2
Do Until lngPosition = 1
lngPosition = InStr(lngPosition + 1, strCreatePath, "\")
If lngPosition > 0 Then
strPath = Left$(strCreatePath, lngPosition - 1)
If Not Len(Dir(strPath, vbDirectory)) > 0 Then MkDir strPth
End If
lngPosition = lngPosition + 1
Loop
fnCreateBasePath = Len(Dir(strPath, vbDirectory))
ExitRoutine:
On Error Resume Next
Exit Function
ErrorHandler:
With Err
Select Case .Number
Case Else
MsgBox .Number & vbCrLf & .Description & vbCrLf & vbCrLf & _
" Error in creating Folder: '" & strCreatePath & "'", _
vbInformation, "Error - fnCreateBasePath"
End Select
End With
'Resume 0
Resume ExitRoutine
End Function
Call it like so:
fncreatebasepath("C:\min\max\boo")
I culled this from some other work that I had done that had a guaranteed
fixed path so I was able to initialize lngposition at 22. It formerly
worked with UNC and mappings but this is just a quick post without testing
because, as I said, I always had a fixed starting path.
Ciao
Jürgen Welz
Edmonton, Alberta
jwelz at hotmail.com
_________________________________________________________________
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines