Hi ED
this was a great solution to work with, not sure if it was clear in my previous post, but i am sending commands from Excel
I had to adjust code to work with my needs
not sure if i did mistake but if statement below was returning value 0 so i adjust it to = 0 so it can close object
'If GetAsyncKeyState(VK_ESCAPE) > 0 Then
also i adjusted close command to edit last polyline and close it, as close by itself will close AutoCAD
'ThisDrawing.SendCommand "_pedit" & vbCr & "_select" & vbCr & "_LAST" & vbCr & "_CLOSE " & vbCr
new ESC function changes become
' ESC Function canges
'If GetAsyncKeyState(VK_ESCAPE) = 0 Then
''close command triggered
'closeKeyPressed = True
'ThisDrawing.SendCommand "_pedit" & vbCr & "_select" & vbCr & "_LAST" & vbCr & "_CLOSE " & vbCr
'End If