I need to print a document plus all respones.
Of course I could simply select all documents to be printed from the UI, select the correct print options and print.
But this procedure seems to be too complicated for our users. Therefore I would like to offer them a print button to print the selected document plus all responses.
So far I have failed to find the appropriate function(s) for document selection and printing in the formula language or in lotusscript. Could anybody help, please?
Thank you very much in advance
Ruedi Berger
Subject: Print current document plus all responses
you could use a view categorized, then with a GetAllDocumentsByKey, build a NotesDocumentCollection of all the documents you want to print, loop through all the documents in your NotesDocumentCollection and open them in the UI using the EditDocument of the NotesUIWorkspace. That will return you a NotesUIDocument, which you can then in turn print using the Print method of the NotesUIDocument. After that, just close the UIDocument and proceed to the next document.
Note: In my experience, even if you close the UIDoc right away, it seems that Notes keeps them open while printing, closing them all at once after it is done printing, and I got some errors when trying to print large amount of documents. User beware I guess…
Subject: RE: Print current document plus all responses
Thank you for your suggestions. I kind of remember that I did something similar a while ago, but I think that each document was opened in UI before printing which didn’t really satisfy users.
Additionally I have to admit that the documents should be printed without pagebreaks. So I thought I might move the documents to be printed to a folder, select all documents in this folder and print them. Which would result in something like this:
@Command([EditSelectAll]);
@Command([FilePrint];“”;“”;“”;“”;“”;“”;“line”);
Selecting and moving the documents to the folder seems easier to be done with LotusScript. But I haven’t found in LotusScript anything to select all documents in a view (like [EditSelectAll] in formular language. Do you have some tip?
Maybe I have to combine LotusScript and Formular agents to achieve. Right now I don’t yet know a solution.
Subject: RE: Print current document plus all responses
To select all the documents form a view? You can use the AllEntries property of the Notes view which returns a NotesViewEntryCollection, and then invoke the PutAllInFolder method of the NotesViewEntryCollection to move them.
And about the documents opening, that cannot be avoided since the print is a UI function, that means that the document must be open for that.
Subject: RE: Print current document plus all responses
Yes, print is a method of NotesUIDocument, so I have to have a open a document to print it.
But print is also a method of NotesUIView and “Prints the selected document(s)” (as stated in help). So if I could somehow mark the desired documents in the view (not manually, but through some LotusScript commands), I might be able to print them using NotesUIView.Print. But so far I haven’t yet found a way to programmatically select documents in a view. Any ideas would be very welcome!
Subject: RE: Print current document plus all responses
Hmmm, ok, so you want to put a selection check besides every documents in the view…
have you tried just putting the printview parameter of the print to false?
Subject: RE: Print current document plus all responses
Sorry that it took me a while to answer. I haven’t followed the thread for some days.
Putting the printview parameter to false only seems to print ONE selected document.
In the meantime I have found a solution to my problem (not a very elegant one, but working):
In an agent I call three other agents. The first one is a script agent that moves the documents to be printed to a folder (the folder is emptied before).
The second agent is a formula agent containing the following commands:
@Command([OpenView]; “PrintFolder”; “”; “0”);
@Command([ViewRefreshFields]);
@Command([EditSelectAll]);
@Command([FilePrint]; “1”;“”;“”;“”;“”;“”; “”);
@Command([FileCloseWindow])
It opens the folder where the documents to be printed have been moved to, selects them all and prints them. For this part I haven’t found a LotusScript solution.
The third agent simply clears the folder (could possibly be done in the formula agent as well).
As I said, not really great programming but still working fine.
Ruedi