Function copyFile(Byval sSource As String, Byval sDestination As String, Byval bOverWrite As Integer) As Integer
On Error Resume Next
copyFile = False
If isFile(sSource) Then
If bOverWrite Or (Not isFile(sDestination)) Then
Filecopy sSource, sDestination
If isFile(sDestination) Then copyFile = True
End If
End If
End Function
例子:
If copyFile("c:/temp/temp.doc", "c:/documents/temp.doc") Then
Msgbox "File c:/temp/temp.doc was copied successfully ."
Else
Msgbox "File c:/temp/temp.doc was NOT copied."
End If