I'm trying to skip over files/folders that that throw "permission denied" but I don't really understand error handlers. I want it thus that if it there is an error thrown, it will skip to the next file or folder. My struggle here is understanding where to call it to resume in the code if I want to proceed to the next iteration or file/folder at hand. I'm also not sure if it should be 2 different error handlers for both file and folder loops.
If Not FSO.folderexists(DestinationFolder) Then FSO.Createfolder DestinationFolder
On Error GoTo NextFile
For Each oFile In FSO.Getfolder(Sourcefolder).Files
If FSO.getextensionname(oFile.Path) <> "pdf" Then
FSO.copyfile oFile.Path, DestinationFolder & " \ " & oFile.Name
Else
End If
Next oFile
For Each oFolder In FSO.Getfolder(Sourcefolder).SUbfolders
backupfiles oFolder.Path, DestinationFolder & " \ " & oFolder.Name
Next oFolder
NextFile:
Resume NextFile2
NextFile2:
Next oFile
End Sub