كاتب المشاركة : نور نبهان
النسخ و النقل من خلال الدوال
كود :
Private Declare Function CopyFile Lib "kernel32" Alias _
"CopyFileA" (ByVal lpExistingFileName As String, ByVal _
lpNewFileName As String, ByVal bFailIfExists As Long) As Long
Private Declare Function MoveFile Lib "kernel32" Alias _
"MoveFileA" (ByVal lpExistingFileName As String, ByVal _
lpNewFileName As String) As Long
Sub CopyMove()
Dim strSource As String
Dim strTarget As String
Dim lngRetVal As Long
strSource = "C:\yfile.txt"
strTarget = "C:\indows\yfile.txt"
'// Copy File
lngRetVal = CopyFile(Trim$(strSource), Trim(strTarget), False)
If lngRetVal Then
MsgBox "File copied!"
Else
MsgBox "Error. File not moved!"
End If
'// Move File
lngRetVal = MoveFile(Trim$(strSource), Trim(strTarget))
If lngRetVal Then
MsgBox "File moved!"
Else
MsgBox "Error. File not moved!"
End If
End Sub