Testing for a directory

  • Thread starter Thread starter MarkS
  • Start date Start date
M

MarkS

Hi,
I need to test if a directory exists and if not create it. All I can think
of is to use on error and try and open it, they create a new directory if it
fails.
Any sugestions of a more elegant way
 
This works for me.....

Dim sFolder As String
sFolder = "C:\NewFolder"

If Dir(sFolder, vbDirectory) = "" Then MkDir sFolder
 
Just create it with error warp

On Error Resume Next
MkDir myDir
On Error Goto 0
 
Thanks that work just great

Nigel said:
This works for me.....

Dim sFolder As String
sFolder = "C:\NewFolder"

If Dir(sFolder, vbDirectory) = "" Then MkDir sFolder


--

Regards,
Nigel
(e-mail address removed)
 
Back
Top