Làm sao coppy được 2 file các Anh....
C:\file1 to C:\folfer1
C:\file2 to C:\folfer2
Mong Các anh giúp em với....
Code này em coppy 1 file thì chạy ngon
Còn muon coppy 2 file tới 2 đích khác nhau, không biết làm thế nào
Em tìm mãi không thấy chỗ nào có
C:\file1 to C:\folfer1
C:\file2 to C:\folfer2
Mong Các anh giúp em với....
Code này em coppy 1 file thì chạy ngon
Còn muon coppy 2 file tới 2 đích khác nhau, không biết làm thế nào
Em tìm mãi không thấy chỗ nào có
Mã:
Sub Copy_Certain_Files_In_Folder()
Dim FSO As Object
Dim FromPath As String
Dim ToPath As String
Dim FileExt As String
FromPath = "C:\" '<< Change
ToPath1 = "C:\TaiLieu1\" '<< Change
ToPath2 = "C:\DuLieu1\" '<< Change
FileExt1 = "abc.xlsx" '<< Change
FileExt2 = "bd.xlsx"
If Right(FromPath, 1) <> "\" Then
FromPath = FromPath & "\"
End If
Set FSO = CreateObject("scripting.filesystemobject")
If FSO.FolderExists(FromPath) = False Then
MsgBox FromPath & " doesn't exist"
Exit Sub
End If
If FSO.FolderExists(ToPath1) = False Then
MsgBox ToPath & " doesn't exist"
Exit Sub
End If
FSO.copyfile Source:=FromPath & FileExt1, Destination:=ToPath1
FSO.copyfile Source:=FromPath & FileExt2, Destination:=ToPath2
MsgBox "You can find the files from " & FromPath & " in " & ToPath
End Sub