View Single Post
  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

Sub test()

If Not FolderExists("C:\Bob") Then
MkDir "C:\Bob"
End If

End Sub

'-----------------------------------------------------------------
Function FolderExists(Folder) As Boolean
'-----------------------------------------------------------------
Dim sFolder As String
On Error Resume Next
sFolder = Dir(Folder, vbDirectory)
If sFolder < "" Then
If (GetAttr(sFolder) And vbDirectory) = vbDirectory Then
FolderExists = True
End If
End If
End Function


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Sri" wrote in message
...
Hello,

When I try to save an excel file using VBA and the folder
name mentioned in the filepath is not available, then
excel gives a error message..is there any way to force
excel to crate the folder and the save the file
accordingly..

I use FilesystemObject to create folders now...but just
wanted to know if there is any other way of doing the
same!!

Thanks,
Sri