Until recently the following code has been executing without any issues.
Sub MoveFiles() Dim FSO As Object Dim FromPath As String Dim ToPath As String Dim FileExt As String Dim fNames As String Application.DisplayAlerts = False ActiveWorkbook.SaveAs Filename:= _ "K:\Bus\Plan\Daily MailBox Count\MailCount Peer.xlsm", FileFormat:= _ xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False Application.DisplayAlerts = True FromPath = "K:\Bus\Plan\Daily MailBox Count\" ToPath = "K:\Bus\Plan\Daily MailBox Count\Current Year Mail Count Archive\" FileExt = "*Mailbox Count Report*" fNames = Dir(FromPath & FileExt) If Len(fNames) = 0 Then MsgBox "No files in " & FromPath Exit Sub End If Set FSO = CreateObject("scripting.filesystemobject") FSO.MoveFile Source:=FromPath & FileExt, Destination:=ToPath ' MsgBox "You can find the files from " & FromPath & " in " & ToPath End Sub
Now for some reason the following code line produces a runtime error 70 'Permission Denied'
FSO.MoveFile Source:=FromPath & FileExt, Destination:=ToPath
The referenced path and folders are located on a network and I continue to have full permission to access and work within the referenced path and folders.
What I have discovered is that even though when the FSO.MoveFile code line is producing the runtime error, before it displays the error the file is actually moved to the destination path and folder.
Can anyone please shed some light on why the the file would be successfully moved but then be followed up with a 'Permission Denied' runtime error ?
Thank you in advance.