Sub Click(Source As Button) Dim s As New NotesSession Dim ws As New NotesUIWorkspace Dim thisdb As NotesDatabase Dim coll As NotesDocumentCollection ' collection returned from PickListCollection Dim otherdoc As NotesDocument ' this is the doc to create a link to Dim thisdoc As NotesDocument ' the new doc that the link is being added to Dim rtitem As NotesRichTextItem ' required for AppendDocLink Dim nitem As Variant ' used to get a handle on the NotesRichTextField Dim olduidoc As NotesUIDocument ' the original instance of the uidoc Dim newuidoc As NotesUIDocument ' the new instance of the uidoc after the doc link has been added Set thisdb = s.CurrentDatabase Set olduidoc = ws.CurrentDocument ' current uidoc Set thisdoc = olduidoc.Document ' doc in memory but hasn't been saved yet ' select the doc to link to Set coll = ws.PickListCollection( PICKLIST_CUSTOM, False, thisdb.Server, _ thisdb.FilePath, "luProject", "Project List", "Please select a project." ) ' if a doc isn't selected exit If coll.Count = 0 Then Messagebox "User canceled" ,,"No project was selected." Exit Sub End If ' get the doc to link to Set otherdoc = coll.GetFirstDocument ' grab some values from that doc thisdoc.ProjectName = otherdoc.ProjectName thisdoc.CustomerName = otherdoc.CustomerName ' get the RichTextField in the current uidoc Set nitem = thisdoc.GetFirstItem( "ProjectDocLink" ) ' add the doc link ' NOTE: this is being done to the backend doc that exists in memory If ( nitem.Type = RICHTEXT ) Then Set rtitem = nitem Call rtitem.AppendDocLink(otherdoc, "Original Doc Link", "") Call rtitem.Update End If ' set the SaveOptions field so that when the uidoc is closed, the user won't be asked to save thisdoc.SaveOptions = "0" ' close the uidoc. It won't actually happen until the code is finished executing Call olduidoc.Close(True) ' create a new uidoc and open the backend doc that is still in memory with added doc link Set newuidoc = ws.EditDocument(True, thisdoc) ' delete the reference to the old uidoc ' this is necessary because the code below affects it if left in memory Delete olduidoc ' re-associate the variable with the backend doc ' have to do this because the olduidoc reference was deleted Set thisdoc = newuidoc.Document ' remove the SaveOptions field so the doc can be saved Call thisdoc.RemoveItem( "SaveOptions" ) End Sub
Sascha, ich würde sagen, der Fred ist hier schon richtig - der Ausgang ist ja ein Tipp.Bernhard