using On Error Resume Next
to skip any error on the below code,But it dose not work.
I got error File not found on the second VBA name command
.
I know that code can be modified to check existence of the file before rename.
I need to know why On Error Resume Next
did not skip that error.
Thanks for your helping.
Sub Name_Test()
On Error GoTo Pause
Dim oldName As String: oldName = "C:\Users\Waleed\Desktop\Test.txt"
Dim newName As String: newName = "C:\Users\Waleed\Desktop\Done.txt"
Name oldName As newName
Pause:
On Error Resume Next
Application.Wait Now + TimeValue("00:00:01")
Name oldName As newName
ThisWorkbook.Save
End Sub