S Steven M. Britton Jun 15, 2004 #1 How can I check to see if a directory exists and if it doesn't make it and if it does export my file into it.
How can I check to see if a directory exists and if it doesn't make it and if it does export my file into it.
J jmonty Jun 15, 2004 #2 Try something like this: If Len(Dir("C:\Test", vbDirectory)) > 0 Then FileCopy "C:\source.txt", "D:\destination.txt" End If substitute your file/directory names or string variables for the directory and file paths/names if you'd prefer.
Try something like this: If Len(Dir("C:\Test", vbDirectory)) > 0 Then FileCopy "C:\source.txt", "D:\destination.txt" End If substitute your file/directory names or string variables for the directory and file paths/names if you'd prefer.
S Steven M. Britton Jun 15, 2004 #3 Seems my most important part of the question was overlooked. How can I check to see if a directory exists and if it doesn't make it.
Seems my most important part of the question was overlooked. How can I check to see if a directory exists and if it doesn't make it.
D Douglas J. Steele Jun 15, 2004 #4 If Len(Dir("C:\Test", vbDirectory)) = 0 Then ' Directory doesn't exist. Create It MkDir "C:\Test" End If Note that you cannot do If Len(Dir("C:\Test\Subfolder", vbDirectory)) = 0 Then ' Directory doesn't exist. Create It MkDir "C:\Test\Subfolder" End If if Test doesn't already exist.
If Len(Dir("C:\Test", vbDirectory)) = 0 Then ' Directory doesn't exist. Create It MkDir "C:\Test" End If Note that you cannot do If Len(Dir("C:\Test\Subfolder", vbDirectory)) = 0 Then ' Directory doesn't exist. Create It MkDir "C:\Test\Subfolder" End If if Test doesn't already exist.