Nelson78
Well-known Member
- Joined
- Sep 11, 2017
- Messages
- 526
- Office Version
- 2007
Hello everybody.
I've to copy a file from a folder and save it to another folder.
The folder that contains the file can be zip or not, I cannot know this info in advance.
Anyway, no problem if the folder is not "zip", I can achieve ("if" part of the code below).
Instead, if the folder is a zip one, the copy an paste operation doesn't work ("elseif" part of the code below).
As you can see, if the folder is zip, the path changes with the add of
How can I figure it out?
I've to copy a file from a folder and save it to another folder.
The folder that contains the file can be zip or not, I cannot know this info in advance.
Anyway, no problem if the folder is not "zip", I can achieve ("if" part of the code below).
Instead, if the folder is a zip one, the copy an paste operation doesn't work ("elseif" part of the code below).
As you can see, if the folder is zip, the path changes with the add of
VBA Code:
& Cell.Offset(0, 2).Value & ".zip\" &
How can I figure it out?
VBA Code:
Dim FromPath As String
Dim ToPath As String
If FileExists("\\10.100.000.001\folder1\" & Cell.Offset(0, 2).Value & "\" & Cell.Offset(0, -3).Value & ".pdf") Then
FromPath = "\\10.100.000.001\folder1\" & Cell.Offset(0, 2).Value & "\" & Cell.Offset(0, -3).Value & ".pdf"
ToPath = "Z:\Folder2\YELLOW\" & Cell.Offset(0, -3).Value & ".pdf"
FileCopy FromPath, ToPath
ElseIf FileExists("\\10.100.000.001\folder1\" & Cell.Offset(0, 2).Value & ".zip\" & Cell.Offset(0, 2).Value & "\" & Cell.Offset(0, -3).Value & ".pdf") Then
FileCopy FromPath, ToPath
End if