Consulting

Results 1 to 3 of 3

Thread: Using MkDir and FileCopy

  1. #1
    VBAX Expert
    Joined
    Feb 2005
    Posts
    929
    Location

    Using MkDir and FileCopy

    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:
    1. create the new directory
    2. pause and manually remove the read-only check
    3. copy the files
    everything 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.
    Last edited by MWE; 11-28-2006 at 06:49 PM.
    "It's not just the due date that's important, it's also the do date" [MWE]

    When your problem has been resolved, mark the thread SOLVED by clicking on the Thread Tools dropdown menu at the top of the thread.

  2. #2
    VBAX Regular
    Joined
    Jul 2005
    Posts
    30
    Location
    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.

  3. #3
    VBAX Newbie
    Joined
    Apr 2006
    Posts
    1
    Location
    Did you change to the new directory after you created it this might help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •