Sendkeys is the culprit. You should roll out your own Sendkeys, like:
Public Sub MySendKeys(Byval strString As String, Byval Option bolWait As Boolean =False)
With CreateObject("WScript.Shell")
.SendKeys strString, bolWait
End With
End Sub
to use in your code replace:
Sendkeys ("{esc}")...