Doc.Remove(true) after closing the document

Hi everyone! The following code puzzles me:

(agent is run from action button within a document)

Dim unid As String

unid = ws.CurrentDocument.Document.UniversalID

…

Call ws.CurrentDocument.Close()

Set doc = s.CurrentDatabase.GetDocumentByUNID(unid)

Call Doc.Remove(true)

Doc is not removed. Why?

“Plain” deletion (i.e. call of Remove when document is Opened in a ui) is impossible.

Thanks in advance,

Dmitry

Subject: Doc.Remove(true) after closing the document

I believe you’ll have problems because the document is still in memory as it was retrieved (via the WS, uidoc, document).

Try adding:

Erase ws

just before the Set doc=… line to ensure it is removed from memory.

HTH - Rufus.