Private Declare Function CopyFile Lib "kernel32.dll" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long Private Sub Form_Load() Dim retval As Long ' return value ' copy the file retval = CopyFile("D:\sample.txt", "D:\example.txt", 1) If retval = 0 Then ' failure MsgBox "Copy failed -- D:\example.txt already exists." Else ' success MsgBox "Copy succeeded." End If End End Sub