Print Current Document Using Lotusscript

I have read, researched, fiddled with, etc, for hours now. And while I assume this is simple, I cannot figure it out. I will add that I am not a designer/programmer, but a Domino Admin.

I found this link http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/6506dc31f80b5f418525710f000b99bb?OpenDocument

which after tweaking a bit, is perfect for our needs. I just need it to do one last thing. Print the email with the attachment.

Even using the lines right out of the Help, it errors:

Dim uidocThis As NotesUIDocument

Dim ws As New NotesUIWorkSpace

Set uidocThis = ws.CurrentDocument

Call uidocThis.Print(1)

I have my guesses as to why this might be happening, but I am having a hard time finding the correct code for an agent (believe it or not).

If anyone has any input on what code to use and where exactly it needs to go, it would be so greatly appreciated.

Thanks VERY much in advance.

Subject: Print Current Document Using Lotusscript

You mention that your code is running in an Agent. Note the following restrictions for NotesUIWorkspace…

“You cannot use the UI classes in a background agent, an agent called trough an API, or an agent called by the NotesAgent Run method. Only workstation users can run scripts that access UI objects.”

Subject: RE: Print Current Document Using Lotusscript

Thank you for your response.If I understand correctly what you posted…this agent will be manually run by a user at a workstation. Not on a schedule or on the server.

Is there not a way to print the selected email in the agent?

Thanks.

Subject: RE: Print Current Document Using Lotusscript

We can help you better if, when there’s an error, you say what the error is and what line it occurs on. See Debugging Domino Applications part 1 and part 2 for some tips on locating the problem yourself.

You say you want to print the “selected” email. If you mean this in terms of selection in a view, then there is no current NotesUIDocument in that situation, so I guess the error you’re getting is “Object variable not set”. A NotesUIDocument represents the document you’re editing on screen. For printing from a view, see NotesUIView.Print method. If you’re not doing anything that requires LotusScript, you might also look at the @Commands for printing.

Subject: RE: Print Current Document Using Lotusscript

I am sorry, I thought I posted the error…Yes, it is Object variable Not Set. I have used the Debug application as best as I can figure it out and does appear to be failing on the Call uidocThis.Print(1) line.

What we want to do it multi select several emails from the inbox of a mail file, and run an agent that will print the email and the attachment of each selected email.

But its sounding like this is not possible.

Thank you for your response.

Subject: RE: Print Current Document Using Lotusscript

You can print the emails from a view with NotesUIView.Print, as I said.

It’s probably going to be a challenge to print the emails and the attachments in proper order (as opposed to all the emails and then all the attachments). But you could do it if you don’t mind a little flashing while you run the agent – it would have to first get the list of selected documents, but after that it could deselect them all, then reposition to each one using SelectDocument, print that one, and then print the attachments. Of course, there’s no “print attachment” function in Notes because printing an attachment in a proprietary format (MS Word, for instance) requires you to run an application that understands that format. But you could detach the files and then use OS functions to try to print them.

Subject: RE: Print Current Document Using Lotusscript

Alright, I’ll look into that.Thank you for your input.

Subject: Print Current Document Using Lotusscript - RESOLVED

I tried using the NotesUIView.Print and IT WORKS!!!Thank you SO very much. Not being a designer, this took several days to work on and figure out. I certainly learned something this time.

Thanks again.

Subject: RE: Print Current Document Using Lotusscript - RESOLVED

I realise this is an old topic, but I also have been struggling with printing memos and THEN the attachments. Would it be possible to share the solution? I’m half-way there using Printing Utilities Library, just need the fix to print the memo before printing the attachments.

Thanks

James.