Find if directory exists

JonnyArcher

New Member
Joined
Sep 4, 2003
Messages
16
I can get Access to create directories without a problem but obviously I need to know if it already exists otherwise access returns an error.
I've tried
NewDir = "C:\Non Server Calls\" & Me.Group & "\" & Me.Area
If IsNull(Dir(NewDir)) Then
MkDir NewDir
Else: End If

but this always returns true whether or not the directory exists.

Any ideas anyone, I can't find it in any of my books!
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
This appears crass but I believe it to actually be a clean solution.

on error goto MkDirErr1
make the dir
on error goto 0
do the rest of your code

MkDirErr1:
resume next
end sub

Keep in mind that it boldly presumes that the only possible error would be duplication of existing dir. There may be other issues, such as network rights, so you may want to experiment with this and perhaps refine it to use specific error code checking, etc. (Debug it and check Err to see which.)
 
Upvote 0

Forum statistics

Threads
1,221,596
Messages
6,160,716
Members
451,665
Latest member
PierreF

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top