Batch Transfer of Files

  • Thread starter Thread starter Sean
  • Start date Start date
S

Sean

Hello All...

I'm trying to create a script that will allow a user to choose an
existing directory and copy the Excel files to another directory.

I have tried using the following command in Excel:

FileSystemObject.CopyFile source_files, dest_dir, False

This command isn't working as I keep getting Error 424 object required
error. Any ideas on this bug or a sample script that allows the user
to copy multiple files from a user defined directory to another
directory?

Thanks.
Sean
 
If I set a reference (Tools|References) to microsoft scripting runtime, then
this worked ok for me:

Option Explicit
Sub testme()

Dim FSO As Scripting.FileSystemObject
Set FSO = New Scripting.FileSystemObject
FSO.CopyFile "C:\my documents\excel\book*.xls", _
"C:\my documents\excel\test", True

End Sub

Without the reference:
Option Explicit
Sub testme2()

Dim FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.CopyFile "C:\my documents\excel\book*.xls", _
"C:\my documents\excel\test", True

End Sub

I used True to overwrite any file with the same name.
 
Back
Top