Full Version: Check for folder and Create new foler
UtterAccess Forums > Microsoft® Access > Access Forms
Is there a way to check to see if a folder exists, and if not create a new folder.
My application creates several files and I want to be able to put them into thier own folder off of the "My Documents" folder.
R. Hicks
Here is a sub routine that should help you ...
Public Sub CheckAndCreateFolder()
Dim strFolderPath As String
strFolderPath = "C:\YourFolderName"

If Len(Dir(strFolderPath, vbDirectory)) = 0 Then
  MkDir strFolderPath
End If
End Sub

Jack Cowley
Ricky -
It sure is nice to see your smiling green face! And I miss seeing your name at the top of the post count, but I guess the software wont handle a number that large...
Otrust you are well, happy and still making bricks at breakneck speed...
Jack aka The Old Goat
An alternative to Ricky’s method is to use the MakeSureDirectoryPathExists API call.
The advantage is that it can make multi-depth directories in one hit.
Public Declare Function apiCreatePath Lib "Imagehlp.dll" _
                 Alias "MakeSureDirectoryPathExists" (ByVal strPath As String) As Long

Private Sub TestIt()
     apiCreatePath "C:\Documents and Settings\Administrator\My Documents\Test\Test\Fred\"
End Sub

Hope that helps.
R. Hicks
I had to have surgery to clear blocked arteries in my lower abdomen.
I have what is known as PAD (peripheral artery disease).
I had the surgery on 02/06/2008. They said it will take about 8 to 10 week to get over it.
I am doing great, I have not had any complications (yet). I stomach area is very sore from the incision but it’s getting better every day.
Jack Cowley
Dang Ricky! I am sorry to hear that you had to have your guts messed with, but you are well on the road to recovery and that is GREAT NEWS!!! I guess this means no more stacking bricks for a while, which is probably OK with you. I bet you are wearing slip-on shoes so you don't have laces to tie... And I bet you don't cinch your belt to the last notch either...
oes this mean no more Southern fried chicken for you? :(
Thank you for the update and do take very good care of yourself!!!
The Old Goat
R. Hicks
LOL ... it means "no more fried anything".
... and I quit smoking back in July (3 pack a day habit) ... what is the world coming to ???
Jack Cowley
I had no idea you were puffing 3 packs a day!! Now that you have quit smoking I am sure that fried chicken was probably tasting better than ever and now that is out too!!! And all that lean horse meat in your freezer... You're right, what is this world coming too? There may be some good news in all of this and that is you will be with us a lot longer (YEEHAA!!!) AND I don't think beer has any of the bad side effects that you find in fried foods...
Please take good care of yourself and I am very happy to hear that you have given up the coffin nails and are eating cauliflower and broccoli....
The Old Goat
R. Hicks
.... wink.gif
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.