Print Selected documents in a view with lotus script

Hello !I´m new in creating lotus script code.

Now I want to do the following thing:

I want to print (just the first page) of selected documents in view.

My created code print the just the first page (that´s allright), but just the first selected page was printed and not the other selected documents.

What´s wrong in the code. Any help is welcome !!

I´ve created the following code:

Sub Click(Source As Button)

Dim session As New NotesSession

Dim db As NotesDatabase

Dim workspace As New NotesUIWorkspace

Dim collection As NotesDocumentCollection

Dim doc As NotesDocument

Dim uiview As NotesUIView

Set db = session.CurrentDatabase

Set uiview = workspace.CurrentView

Set collection = db.AllDocuments

Set doc = collection.GetFirstDocument

Call uiview.SelectDocument(doc)

Call uiview.Print(1, 1, 1  )

End Sub

Subject: Look at the UnprocessedDocuments property

In Notes help look for the unprocesseddocuments property of the NotesDatabase Classs…in your usage the selected documents in the view will make up your collection e.g.

Dim db as NotesDatabase

Dim session as New NotesSession

Dim dc as NotesDocumentCollection

Set db = session.CurrentDatabase

Set dc = db.Unprocesseddocuments

Subject: changed my code…without my wanted result

Hi !thanks for your help. Now I changed my script.

But I have the same problem.

I mark several documents in a view for printing.

Problem is: just the first marked document is printing !

Maybe you can have a look on my changed script.

Thanks in advance.

Sub Click(Source As Button)

Dim session As New NotesSession

Dim db As NotesDatabase

Dim workspace As New NotesUIWorkspace

Dim collection As NotesDocumentCollection

Dim doc As NotesDocument

Dim uiview As NotesUIView



Set db = session.CurrentDatabase

Set uiview = workspace.CurrentView

Set collection = db.unProcesseddocuments 

Set doc = collection.GetFirstDocument

Call uiview.SelectDocument(doc)

Call uiview.Print(1, 1, 1  )

End Sub

Subject: You need a loop

Something like:

Set doc= collection.GetFirstDocument

Do Until doc Is Nothing

Call uiview.SelectDocument(doc)

Call uiview.Print(1, 1, 1  )

Set doc= collection.GetNextDocument(doc)			

Loop

Succes!

Dirk

Subject: with the loop the first marked document printed several times …help

Hi ! thanks for your help.now I changed the code again.Now I´ve the following result:

I mark 3 documents in a view. With this code just the first marked documents printed but 3 times. !!

Maybe you can have a look again !!!

Sub Click(Source As Button)

Dim session As New NotesSession

Dim db As NotesDatabase

Dim workspace As New NotesUIWorkspace

Dim collection As NotesDocumentCollection

Dim doc As NotesDocument

Dim uiview As NotesUIView



Set db = session.CurrentDatabase

Set uiview = workspace.CurrentView

Set collection = db.unProcesseddocuments 



Set doc= collection.GetFirstDocument



Do Until doc Is Nothing

	

	Call uiview.SelectDocument(doc)

	Call uiview.Print(1, 1, 1 )

	Set doc= collection.GetNextDocument(doc) 

	

Loop

End Sub

Subject: This works:

Very strange indeed. Once you specify the second and third parameter in call uiview.print(1,1,1) you loose your document selection and you get an error message at the bottom of your screen.

So print the front end document.

Use this code assuming you previously selected some documents in the view in which you put this button.

Sub Click(Source As Button)

Dim session As New NotesSession

Dim db As NotesDatabase

Dim collection As NotesDocumentCollection

Dim doc As NotesDocument

Dim uiws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument



Set db = session.CurrentDatabase

Set collection = db.UnprocessedDocuments



Set doc= collection.GetFirstDocument



Do Until doc Is Nothing

	

	Set uidoc = uiws.EditDocument(False,doc)

	Call uidoc.Print(1,1,1)		

	Call uidoc.Close

	Set doc= collection.GetNextDocument(doc)			

	

Loop

End Sub