Hallo zusammen.
Ich habe probleme mit einer Funktion.
Ich will über eine Aktion in einem Dokument eine Kopie dieses Dokumentes erstellen. Das ganze sollte geschehen, ohne das orignial im Edit-Modus zu öffnen (bzw. im Backend-Bereich).
Ich habe in der Notes-Hilfe folgende Code gefunden:
Dim session As New NotesSession
Dim db As NotesDatabase
Dim docA As NotesDocument
Dim docB As NotesDocument
Set db = session.CurrentDatabase
'...set value of docA...
Set docB = New NotesDocument( db )
Call docA.CopyAllItems( docB, True )
Call docB.Save( True, True )
Dieser funktioniert jedoch nicht.
Hat jemand eine Idee, wie ich das lösen kann ?
Vielen Dank im voraus.
Gruß
Sebastian
... als BEiSPIEL !:
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim notesDate As New NotesDateTime ("")
Dim docNew As NotesDocument
Dim rtitem As NotesRichTextItem
Dim varDummy As Variant
Set db = session.currentDatabase
Set uidoc = ws.currentDocument
Set doc = uidoc.document
varDummy = ws.Prompt( PROMPT_YESNO, "Schliessen", "Sie wollen eine neue Insolvenz öffnen. " _
& Chr(13) & "Möchten Sie wirklich fortfahren ? "_
& Chr(13) + "Danach kann das Dokument nicht mehr bearbeitet werden !!!")
If Not Cstr(varDummy) = "1" Then
Exit Sub
End If
If Trim(doc.name(0)) = "" Or Trim(doc.strasse(0)) = "" Or Trim(doc.plz(0)) = "" Or Trim(doc.ort(0)) = "" Then
Msgbox "Einige Felder sind noch nicht ausgefüllt. " _
& Chr(13) + "Aktion wird abgebrochen !"
Exit Sub
End If
Call notesDate.setNow
doc.akte_ende = notesDate.dateOnly
Call doc.save(True, False)
Call uidoc.close
Set docNew = db.createDocument
docNew.Form = "maske_insolvenz"
docNew.name = doc.name(0)
docNew.HRB = doc.HRB(0)
docNew.strasse = doc.strasse(0)
docNew.plz = doc.plz(0)
docNew.ort = doc.ort(0)
docNew.akte_beginn = notesDate.dateOnly
Set rtitem = New NotesRichTextItem( docNew, "sonstiges" )
Call rtitem.AppendDocLink( doc, "Link zur AGS" )
Call docNew.save(True, True)
Set uidoc = ws.EditDocument(True, docNew)
End Sub