Documents not sorted as needed when exported into Excel

Hello there.

I’m working on an application that exports the columns from Lotus Notes to Excel. This is a summary on how my program works.

  1. Employee documents are sorted according to the Hire Date, not creation date in a view.

  2. A user ticks the needed document. The unprocesseddocument method is used.

  3. Since the some of the fields that needs to be exported into excel is encrypted, the fields are empty inside the view. So to export the encrypted fields, selected document is opened one by one in edit mode before datas are extracted into the excel file.

  4. Document is closed and the next document is opened.

So my current problem now is, the documents that are selected and opened are not being selected according to view in which it is sorted. The documents are selected by it’s creation date instead. I know there’s a class called NotesViewEntry that selects a document according to how it’s sorted in a view, but I can’t seem to use it as I need to use NotesDocumentCollection class to select the ticked document.

If I use only NotesViewEntry to select the wanted documents, I can’t get it to select only the ticked documents. And when I use NotesDocumentCollection only, the documents sequence is not the same as it’s original sequence inside the view.

So my question here, how do I get the NotesViewEntry class and NotesDocumentCollection class to work with each other?

Here’s a portion of the coding, it’s actually very long, but I took out the part where it exports the code to excel.

Sub Click(Source As Button)

Dim workspace As New NotesUIWorkspace

Dim session As New NotesSession

Dim db As NotesDatabase

Dim view As NotesView

Dim collection As NotesDocumentCollection

Dim doc As NotesDocument

Dim maxFiles As Integer, i As Integer

Dim scope As String

Dim rows As Integer, cols As Integer, maxcols As Integer

Dim excel As Variant

Dim excelSheet As Variant

Dim  colvals As Variant

Dim K As Integer

Dim c As NotesViewColumn

Dim Filename  As String

Dim x As Integer

Dim refNo As String

Dim item As Variant

Dim xlVarFileName As Variant

Dim xlFilename As String

Dim salary As String

Filename = Inputbox(" Enter filename :")

refNo = Inputbox("Enter Reference Number:")

Dim y As Variant



rows=2

cols =1	



Set db = session.CurrentDatabase

Set view = db.GetView("Main Form")

Set collection = db.UnprocessedDocuments



Set doc = collection.GetFirstDocument

For x= 0 To collection.Count-1

	Dim uidoc As NotesUIDocument

	Set uidoc = workspace.EditDocument(True,doc)

	

Next x

End Sub

Thank you for your kind attention :slight_smile:

Subject: Documents not sorted as needed when exported into Excel

Have you tried using a NotesViewEntryCollection?

Subject: RE: Documents not sorted as needed when exported into Excel

I have tried using both NotesView Entry and NotesViewEntryCollection together, but when I use it, it cannot select only the ticked documents in the view, so I used NotesDocumentCollection only instead. Is there any way we can assign the files from unprocessedDocuments to NotesViewEntryCollection? If there is, then my problem might be solved :slight_smile:

Subject: Documents not sorted as needed when exported into Excel

You could sort the document collection, see here:http://www-10.lotus.com/ldd/46dom.nsf/55c38d716d632d9b8525689b005ba1c0/02b266a5e5d6b90185256bbf0076813b?OpenDocument