Hello All,
I am trying to copy a file "x" to multiple folders based on a condition using FSO.copyfile as below
1 For k = 1 To Lastrow
2 movepath1 = filepath0 & "\" & Cells(k, 1).Value
3 If InStr(Cells(k, 4).Value, "Human") > 0 Then
4 Set FSO1 = CreateObject("Scripting.FileSystemObject")
5 movepath2 = folderpath2 & "\Human\"
6 FSO1.copyfile Source:=movepath1, Destination:=movepath2
7 Set FSO1 = Nothing
8 End If
9 If InStr(Cells(k, 4).Value, "Field_staff") > 0 Then
10 Set FSO1 = CreateObject("Scripting.FileSystemObject")
11 movepath2 = folderpath2 & "\Fieldstaff"
12 FSO1.copyfile Source:=movepath1, Destination:=movepath2
13 Set FSO1 = Nothing
14 End If
15 Next k
However, I am seeing "Permission denied" error at line number 12 incase same file is referred for copying.
Please help me with some leads.
Bookmarks