The easiest way to do this is to call this agent via ?OpenAgent from the current document:
Sub Initialize Dim s As New notessession Dim db As notesdatabase Dim rdoc, doc As notesdocument Dim uid As String Dim returnto As String ' Get current document Set rdoc = s.DocumentContext Set db = rdoc.ParentDatabase returnto$=Left(rdoc.http_referer(0),Instr(rdoc.http_referer(0),"?")-33) uid$=Right(Left(rdoc.http_referer(0),Instr(rdoc.http_referer(0),"?")-1),32) Set doc=db.GetDocumentByunID(uid$) ' Get the parent document so that you can bounce the user back to it after the deletion returnto$= Left(returnto$,Instr(Strconv(returnto$,2),".nsf/")+3)+"/all/"+doc.parentdocumentunid+"?Opendocument" Call doc.remove(True) Print "["+returnto$+"]" End Sub