By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
exists and if is doesn't then it creates it. It assumes that the parent
directory exists, so if in doubt then call the function several times starting
at the root.
This is a useful function if, like me, you want to control the detaching of
documents so that they are placed using script in the same sub directory on all
To call the function:
The Function itself:
Function CheckForCreateDirectory(DirPath As String)
'This function checks for a subdirectory given the parent, and if it doesn't
exist it creates it
'Extract the different elements of the full path
Do While continue=False
If Instr(DirName,"\") Then
'Check for directory and add if it doesn't exits
CheckDir = Dir$(ParentDirPath,16)
Do While CheckDir <> ""
If Ucase(CheckDir) = Ucase(DirName) Then
CheckDirFlag = True
CheckDir = Dir$()
If CheckDirFlag=False Then