Function MakeFolder(strPath As String) On Error GoTo MakeFolder_Err If Dir(strPath, vbDirectory) > vbNullString Then Exit Function End If MkDir strPath MakeFolder = True Exit Function MakeFolder_Err: MsgBox "Folder """ & strPath & """ cannot be created." MakeFolder = False End Function
This function creates a directory given a full path string. Note that the enclosing directory needs to exist for this to work. If the directory already exists, the function has no effect.