Results 1 to 2 of 2
2006-11-04, 04:36 #1
- Join Date
- Mar 2004
- Thanked 0 Times in 0 Posts
copy directory in word (Word 2002)
I have written a macro that runs once a day, and takes care of some back up of individual files. Now I would like it to back up some entire directories, but I won't know their contents. I tried to use
FileSystemObject.CopyFolder "Y:200611-03-2006", "C:bkupseal200611-03-2006" which I found in the visual basic help on the form of FileSystemObject.CopyFolder "c:winwordletters*", "c:tempfolder" . When I run it, however, I get an error message..."Run time error "424", Object required" I have checked and doublechecked; the original directory exists, I can type the destination in a dos window and get there, and the destination does not. I have also tried ith with a single * after the last slash in the source folder. In addition, of course, this was only my test run, I eventually want to encorpate a wild card in there and have it read something like
FileSystemObject.CopyFolder "Y:" & MyYear$ & "" & Mydate$ "", "C:bkupseal" & MyYear$ & "" & Mydate$ ""
but of course, actually work. (I know how to do the MyYear$ and Mydate$, I use those elsewhere...Thoughts? <img src=/S/confused.gif border=0 alt=confused width=15 height=20>
2006-11-04, 05:21 #2
- Join Date
- May 2003
- Los Angeles, California, USA
- Thanked 2 Times in 2 Posts
Re: copy directory in word (Word 2002)
To use a method (like CopyFolder) of the FileSystemObject, you have to first create an instance of the FileSystemObject. Try this:
<pre> Dim fso As Scripting.FileSystemObject
Set fso = New Scripting.FileSystemObject
fso.CopyFolder "Y:200611-03-2006", "C:bkupseal200611-03-2006"
Set fso = Nothing</pre>
Please note that I removed the backslashes from the ends of your parameters. This matters. The backslash at the end of the first (source) parameter would generate an error, although it would work if you wanted to add "*.*" after the backslash. The backslash at the end of the second (destination) parameter would (I believe) end up copying the files to C:bkupseal200611-03-2006200611-03-2006, which I assume is not what you want.
Note also that, to use the FileSystemObject, you need to have a Reference set to Microsoft Scripting Runtime.