Function CopyFiles(sourcepath As String, destpath As String) As Integer ' this function copies files from source folder to destination folder ' sourcepath - the source filepath, e.g. c:\temp\ ' destpath - the destination filepath, e.g. w:\archive\ Dim filename As String ' file currently being moved On Error Goto FErrorHandler ' get first file filename = Dir$((sourcepath , 0) ' process files Do While filename <> "" FileCopy sourcepath & filename, destpath & filename ' loop filename = Dir$() Loop ' return success CopyFiles = 1 FExit: Exit Function FErrorHandler: Print "(CopyFiles) Unexpected Error: " & Cstr(Er) & ", " & Error$ & ", on line: " & Cstr(Erl) CopyFiles = 0 Resume FExit End Function