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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top