Hi experts
it gives me error file already exists in this line
when try move file from folder to another
so should move file extraction 10 Oct. 2022 (1).xlsx from directory C:\Users\PC lLATER\Downloads\ to directory
C:\Users\PC WORLD\output\rep
how can I fix error?
how can I add more than file name into array like this ("extraction 10 Oct. 2022 (1).xlsx" , "report.pdf", "pictures.jpg","montly.docx")?
is there any chance to make this code works efficiantly ?
it gives me error file already exists in this line
VBA Code:
FSO.MoveFile Source:=SourcePath & NameFile, Destination:=DestPath
so should move file extraction 10 Oct. 2022 (1).xlsx from directory C:\Users\PC lLATER\Downloads\ to directory
C:\Users\PC WORLD\output\rep
how can I fix error?
how can I add more than file name into array like this ("extraction 10 Oct. 2022 (1).xlsx" , "report.pdf", "pictures.jpg","montly.docx")?
VBA Code:
Sub Move_Folder()
Dim FSO As Object
Dim SourcePath As String
Dim DestPath As String
Dim NameFile As String
SourcePath = "C:\Users\PC lLATER\Downloads\" '<< Change as needed
DestPath = "C:\Users\PC lLATER\output\rep" '<< Change as needed
NameFile = "extraction 10 Oct. 2022 (1).xlsx" '<< Change as needed
Set FSO = CreateObject("scripting.filesystemobject")
If FSO.FolderExists(Left(SourcePath, Len(SourcePath) - 1)) = False Then
MsgBox SourcePath & " doesn't exist"
Exit Sub
End If
'to move
FSO.MoveFile Source:=SourcePath & NameFile, Destination:=DestPath
End Sub