charlie_580
Board Regular
- Joined
- Feb 3, 2007
- Messages
- 53
Hi
I'm using this code to save to a network drive.
If I remove the strDirname2 it will save in the folder as the filename. I need the sub folder to work though as there are 5 possible subfolders.
Any help greatly appreciated.
I'm using this code to save to a network drive.
Code:
Sub save()
Dim strFilename, strDirname, strDirname2, strPathname, strDefpath As String
On Error Resume Next ' If directory exist goto next line
strDirname = Range("X2").Value ' New directory name
strDirname2 = Range("C1").Value
strFilename = Range("T1") & " " & Range("A6") 'New file name
strDefpath = "N:\Returns\" 'Default path name
If IsEmpty(strDirname) Then Exit Sub
If IsEmpty(strDirname2) Then Exit Sub
If IsEmpty(strFilename) Then Exit Sub
MkDir strDefpath & strDirname
strPathname = strDefpath & strDirname & "\" & strDirname2 & "\" & strFilename 'create total string
ActiveWorkbook.SaveAs Filename:=strPathname, _
FileFormat:=xlOpenXMLWorkbookMacroEnabled, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
End Sub
If I remove the strDirname2 it will save in the folder as the filename. I need the sub folder to work though as there are 5 possible subfolders.
Any help greatly appreciated.