Bring newly created document to frontend in order to print

I have a document open, which is my frontend UIDocument. This document has an embedded view and I use every document in this view to create another document, getting values from both the uidocument and the documents in the embedded view. So far so good as you can see from my code. BUT I also want to print this newly created document and this is my question: How do I do that? I suppose I either have to bring the new document to a frontend ui-document (which seems to be the best way) or I keep the newly created documents in a temp view or something and print them from there. Just don’t realize how to to this.

Sub Click(Source As Button)

Dim doc As NotesDocument

Dim docNew As NotesDocument

Dim s As New NotesSession

Dim db As NotesDatabase

Set db = s.currentdatabase

Dim dc As NotesDocumentCollection

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument	



Set uidoc = ws.currentdocument

If (uidoc Is Nothing) Then

	Messagebox "Det finns inget dokument"

	Exit Sub

End If



Set dc = db.UnprocessedDocuments

If dc.count <> 0 Then

	Set doc = dc.GetFirstDocument()

	Do Until doc Is Nothing

		Set docNew = db.CreateDocument

		docNew.Form = "Transportsperma"

		docNew.H_NamnH = uidoc.FieldGetText("H_NamnH")

		docNew.Datum = Cdat(uidoc.FieldGetText("Datum"))

		docNew.Tid = Cdat(uidoc.FieldGetText("Tid"))

		docNew.Transport = doc.Transport

		docNew.Konc = uidoc.FieldGetText("Konc")

		docNew.Mot = uidoc.FieldGetText("Mot")

		docNew.SpV = uidoc.FieldGetText("SpV")

		docNew.Antibiotika = uidoc.FieldGetText("Antibiotika")

		docNew.SpGrT = uidoc.FieldGetText("SpGrT")

		docNew.MESpT = uidoc.FieldGetText("MESpT")

		docNew.DosVolT = uidoc.FieldGetText("DosVolT")

		docNew.SamlNr = uidoc.FieldGetText("SamlNr")

		docNew.SamlNr2 = uidoc.FieldGetText("SamlNr2")

		docNew.H_Namn = doc.H_Namn

		docNew.K_Nr = doc.K_Nr

		docNew.H_Agare = doc.H_Agare

		

		docNew.ComputeWithForm False,False

		docNew.save True,False

		Set doc = dc.GetNextDocument(doc)

	Loop 

	ws.ViewRefresh

	Dim closedView As NotesView

	Set closedView = s.CurrentDatabase.GetView("(NotesThreadsChecklistClosed)")

	If Not closedView Is Nothing Then closedView.Refresh

End If

End Sub

Subject: Found a solution

I finally came to a solution that might be useful for others as well. I wanted to find a script that, for every selected document in an embedded view, create and print a new document using information from the selected one. In order to do that I put the newly created document into a folder, print it and remove it from folder.

… code from my original post

docNew.save True,False

'print

Call docNew.PutInFolder(“FSPrint”)

Call uidb.OpenView(“FSPrint”, , True)

Dim uiview As NotesUIView

pageseparator = 2

Set uiview = ws.Currentview

Call uiview.Print(1, 0, 0, False, pageseparator)

Call docNew.RemoveFromFolder(“FSPrint”)

Call uiview.Close

'next

Set doc = dc.GetNextDocument(doc)