Are there any excel wizards out there who could tell me how to get VBA
to create folders?
Thanks,
Peter
Is the file path fixed or will it change frequently? Creating the
directory isn't so hard:
If Dir(Path, vbDirectory) = "" Then MkDir (Path)
However, if you need to build the path, you could probably modify the
following code to do what you want:
Private Sub MakePath()
Dim Drive As Long
Dim Path As String, Per As String, Bus As String
Dim Store As String, NewFile As String
' these lines define the many variable portions of the folder path and/
or filename
Path = "\\Server\Drive\Folder"
Store = Format(Sheets("Sheet1").Range("E13").Value, "000")
' change the 000 to whatever format you want
Bus = Sheets("Sheet1").Range("J15").Value
Per = Sheets("Sheet1").Range("i5").Value
NewFile = Path & "pd" & Per & "\" & "Store Forecast_" & Bus &
Store & "_" & "pd" & Per & ".xls"
' check to see if Path exists, and creates it if it doesn't...
If Dir(Path & Per, vbDirectory) = "" Then MkDir (Path & Per)
'save the file to the created directory
ActiveWorkbook.SaveAs Filename:=NewFile, FileFormat:=xlNormal
hope this helps!
Ray