Function CreateDir(strSvrPath As String, strDir As String) As Integer ' strSrvPath should be a base filepath -- e.g. c:\temp\ ' strDir should be the additional folder(s) to create ending with a slash -- e.g. \company\client\ordernumber\ Static strConst As String Dim strDirCurr As String, strNextDir As String Dim errnumber As Integer ' for troubleshooting purposes Dim errstring As String ' for troubleshooting purposes strConst = "" strDirCurr = "" strNextDir = "" On Error Goto ProcessError Start: If ( Instr(1, strDir, "\") > 0 ) Then strDirCurr = Strleft(strDir, "\") strNextDir = Strright(strDir, "\") Else ' when no more slashes we stop! CreateDir = 1 Exit Function End If '-- Determine if we need to make the directory, ie. does it exist If ( Dir(strSvrPath & strConst & strDirCurr, 16) = "" ) Then ' doesn't exist, make it Mkdir strSvrPath & strConst & strDirCurr End If strConst = strConst & strDirCurr & "\" ' set working directory to next directory and loop strDir=strNextDir Goto Start ' loop Exit Function ProcessError: errnumber = Err errstring = Error$ ' return something other than 1 CreateDir = 0 Exit Function End Function