If call "FileCopy" method in VBA, an error may occur when copying file from network drive to local computer in my experience.
Therefore, It is necessary to call an alternative method to overcome it.
Below is the code to make use of the FileSystemObject to replace the FileCopy method.
Public Sub CopyFileBypassErr(src As String, des As String)
Dim objFSO As Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
'object.copyfile,source,destination,file overright(True is default)
objFSO.CopyFile src, des, True
Set objFSO = Nothing
End Sub
沒有留言:
張貼留言