create a folder

How would i check if a folder exists and if it doesn't create it?
vbnetcoderAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:
place this code in the top of a regular module

Option Compare Database
Option Explicit
Public Declare Function MakeSureDirectoryPathExists Lib "imagehlp.dll" (ByVal lpPath As String) As Long


to check and create a folder if doesn't exists, simply use this code anywhere in your app

MakeSureDirectoryPathExists "c:\Folder1\Folder2\folder3\"

Open in new window

that will create all the folders \Folder1\Folder2\folder3 if they don't exists
0
vbnetcoderAuthor Commented:
it doesn't seem to like it

Capture.JPG
0
vbnetcoderAuthor Commented:
and if i run the form i get an error telling me that this needs to be update to run on 64 bit
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Rey Obrero (Capricorn1)Commented:
you don't need the "End Function" line in the code
0
vbnetcoderAuthor Commented:
it doesn't matter i get an error either way

Also, it tells me that this will not work on 64 bit systems
0
Rey Obrero (Capricorn1)Commented:
ooh, use the mkdir() function

If Dir(strFullPath, vbDirectory) = vbNullString Then
    'folder doesn't exist, so create it
   mkDir strFullPath

   else

   msgbox "Folder exists"

end if
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rey Obrero (Capricorn1)Commented:
test his one for the 64 bit machine

Public Declare PtrSafe Function MakeSureDirectoryPathExists Lib "imagehlp.dll" (ByVal lpPath As String) As LongLong

Open in new window

0
Rey Obrero (Capricorn1)Commented:
@vbnetcoder

also test this one


Public Declare PtrSafe Function MakeSureDirectoryPathExists Lib "imagehlp.dll" (ByVal lpPath As String) As Long
0
vbnetcoderAuthor Commented:
ty
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.