Copy a folder using vba

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am attempting to copy a folder full of sub-folders and template files and
then would like to rename this copied folder. This new name would correspond
to a field in a form. Does anyone know of a way to do this? The folder I
would like to copy is a "Template Folder" that, like I stated earlier, has
files also in it and multiple sub-directories.

THanks a bunch in advance. Your help is greatly appreciated.
 
I will try that, I guess I was under the impression it only copied files.
Dumb of me to assume i guess.

Thanks for the reply
 
FileCopy will copy a file or a folder. You can give the new folder whatever
name you want.

To rename a folder or file that already exists, use the Name statement.
 
I have been testing this solution with unsatisfactory results. I am
apparently missing something. I can copy a file just fine, renaming also.
However, how would you use this command to copy a folder and all its
contents, not just an indvidual file. Sorry it this is a dumb question.

Thanks
 
oh awesome!

I think I figured it out by using the following code in case you would like
to know.

Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CopyFolder "c:\test1", "c:\test3"

I obviously want it to do more but this is a start. For instance I would
like it to pull a "job number" from a field on my form and rename the parent
folder to that value that would be pulled from the form and etc, but the
basics are at least figured out. one step down, and probably the hardest. a
few more to go. i think i have it from here on though.

I am sure you know about the above code but thought I would let you know how
I was able to solve my problem. Thanks again for you help. Let me know if
know of any issues with this coding also. problems that could arise and
whatnot.
 
Yep, that indeed is the way to do it. I apologize, I was going from memory
about the FileCopy method; I've rechecked the facts, and it does not work to
copy a folder.

Good detective work; sorry for the bum steer!
:-(
 
not a problem at all. You have helped me so many other times by answering
others questions. You all deserve a great big thank you from all of us to
all of you that spend so much time answering all these questions.

Thank You
 
Greg W said:
not a problem at all. You have helped me so many other times by answering
others questions. You all deserve a great big thank you from all of us to
all of you that spend so much time answering all these questions.

Thank You

< blush > You're welcome from all of us!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top