Try commenting out all the code between OpenFile and CloseFile to see if it's this which is causing the hang. If so, you could add the file to an area rather than using OpenFile, to see if that helps.
More explanation @Paul:
When the issue occurs, should see if restarting presence or lookup helps. If so - that is the issue and should be sorted. First need to ensure that that is the issue...
Hello!
You can mark it as closed as option. If document is connected with other documents you can not delete it so you will not be able to delete PO, as you will not be able to remove Goods receipt...