Tom Ogilvy shared this with us in microsoft.public.excel.programming:
On Error Resume Next
Mkdir "c:\Myfolder"
On Error goto 0
Then you are sure it exists.
Or use the CreateFolder method from FileSystemObject:
Function CreateFolderDemo
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.CreateFolder("c:\New Folder")
CreateFolderDemo = f.Path
End Function
There is even a FolderExists method! Call this before creating your
folder.
Function ReportFolderStatus(fldr)
Dim fso, msg
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FolderExists(fldr)) Then
msg = fldr & " exists."
Else
msg = fldr & " doesn't exist."
End If
ReportFolderStatus = msg
End Function
It's a more "modern" way of programming. On Error is rather cluncky and
created spaghetti code, FileSystemObject is really Object Oriented. But
it's not my way or the highway: please try both and use what you like
best.
(Hey, please no discussions about early/late binding. I just copied
this from some page on the MSDN DVD. Don't shoot the messenger.)
--
Amedee Van Gasse using XanaNews 1.17.3.1
If it has an "X" in the name, it must be Linux?
How To Ask Questions The Smart Way
http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively
http://www.chiark.greenend.org.uk/~sgtatham/bugs.html
Only ask questions with yes/no answers if you want "yes" or "no" as the
answer.
http://homepages.tesco.net/~J.deBoyn...-with-yes-or-n
o-answers.html