View Full Version : Solved: testing to see if a Directory exists
DBinPhilly
05-31-2013, 05:29 AM
I'm starting to automatically save PDF copies of certain reports in predetermined locations. I need to copy a file to a particular directory (based upon various criteria), but if the directory does not exist, I want to create the directory on the fly first. Otherwise I will just proceed with the copy.
I'm sure there is a DOS command to do this, but I can't find it.
Your help would be gratefully appreciated.
Doug Robbins
05-31-2013, 09:35 PM
If you run the following code
ChDir "C:\FolderDoesNotExist"
replacing the "C:\FolderDoesNotExist" with the path\directory of interest, you will get a run time error '76':
Path not found
You can then use MkDir to create the folder.
HiTechCoach
06-02-2013, 11:01 AM
You can use built-in VBA functions to perform all the DOS functions to check for a Folder and create if not found.
Check out the VBA commands: Dir() and MKDir()
Note: thise will only create a folder in a folder that already exists. If you need to create a folder and sub folder(s) at the same time then things gets a lot more complicated.
For a way to create folders and sub folders with VBA see: http://www.utteraccess.com/forum/index.php?s=&showtopic=1144399&view=findpost&p=1666959
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.