Getting the selected documents into the document collection and traversing through them for an operation !!!

fatihdi
fatihdi used Ask the Experts™
on
Hi,

I am trying to get the selected documents in a particular database through lotusscript .

I am getting an error in my code below !!! as object not set to a variable,

what am i doing wrong here? How can I solve this problem !!!

If there is no documents selected then a messagebox can pop up and warn the user, if documents selected on those selected documents I want to do some operation !!! How can I achieve it? what would be the way to do that? I am a newbie tnx alot for assistance !!!!!
Dim session As NotesSession
	Dim uiview As NotesUIView
	Dim dc As NotesDocumentCollection
	Dim doc As NotesDocument
	Dim ws As NotesUIWorkspace
	Dim person As NotesName
	Dim db As NotesDatabase
	
    Set db=session.Currentdatabase
    Set dc=db.Unprocesseddocuments
    
    'Set uiview = ws.Currentview
	'Set dc = uiview.Documents
		
	If dc.Count>0 Then

			Set doc = dc.GetFirstDocument
		
			While Not (doc Is Nothing)
			If doc.HasItem ("AdSoyad") Then
		        
		    	Set person=doc.AdSoyad(0)
		        MessageBox("send the mail mf")
		        
			End If
			Set doc = dc.GetNextDocument (doc)
		
			Wend
		
	Else
     		MessageBox("Lütfen Mesaj gönderilecek dokümani seçiniz !!!")
    End If

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Line 1:
Dim session as New NotesSession

New initialises session. If that is not done you can't access it's properties (as done in line 9)

Author

Commented:
yes with your help i passed the first stage but now although no document is selected in the view it gets the first document to the document collection.

If I select documents that i correctly brings the documents i selected to the document collection so I need a way to get the selected documents in a view into the collection, what would be the right way to do it?
should I use view navigators etc...?

can you help me with the code ? thank you
Be aware that you most likely always have at least 1 doc selected: the one your "cursor" is on. Only exception that I know of is a category...

I don't think that I understand  the rest of your question: you have dc as a document collection (i.e. whatever docs you've selected). Do you want to add those document to a view, or do you want additional docs from the view added to the collection? For now my guess is that the collection is ok.

If it is of any use to you, you could also use something like...

dc=db.search({person="AdSoyad"}, nothing, 0)

...to build a collection.

Sjef BosmanGroupware Consultant

Commented:
If you want the selected documents in a view, I think you need to use the view actions. In such an action you can walk through the selected documents.

Otherwise, use the database.UnprocessedDocuments property.
From the Designer Help:
Main subject: LOTUSSCRIPT/COM/OLE CLASSES
article: Collecting all documents and all unprocessed documents

snippet: The UnprocessedDocuments property applies only to agents and view actions. For agents, this property contains all documents not yet processed by the agent or the result of the search specified in the agent's Document Selection object, depending on how you create the agent. For view actions, this property contains all selected documents.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial