PDA

View Full Version : Using MkDir and FileCopy



MWE
11-28-2006, 04:48 PM
I wish to create a new directory and then copy several files into it. all under VBA control. Creating the new diretory with the MkDir command works fine, but when I try to then copy files into that directory using FileCopy, I get a permissions error. When I check the permissions on the directory, it has the "partial check" for Read-Only as is true for any newly created directory. Manually creating a new directory and copying in some files (obviously) does not encounter a permissions problem.

If I split the process into three steps:
create the new directory
pause and manually remove the read-only check
copy the fileseverything works fine.

So, why does VBA get an error when I copy files into a just created directory, but other approachs do not? Is there a way to programatically remove the read-only attribute? Or is there some other way to create the directory and/or copy the files that will work better?

Thanks

UPDATE: well, the VBA gremlins seem to be at work again. I could not get MkDir and FileCopy to work at all yesterday, but today it works just fine.:dunno

jwilder1
11-28-2006, 09:46 PM
Programatically creating blank files with the same file names in the new directory might work( haven't tried it). Also, Adding an extension to the filename will allow file copy to copy it.

kd7m6f
12-02-2006, 06:06 PM
Did you change to the new directory after you created it this might help