List field values of several documents in alphabetical order

This tip will let you select one or more documents and export all its field values in alphabetical field order.

'compare fields:

Option Public
Option Declare
Sub Initialize
    Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim collection As NotesDocumentCollection
    Dim doc As NotesDocument
    Dim i As Integer, j As Integer
    Dim arrValue() As String
    Dim fileNum As Integer
    fileNum% = Freefile()
    Open "C:\temp\compare.txt" For Output As fileNum%

Set db = session.CurrentDatabase
    Set collection = db.UnprocessedDocuments
    For i = 1 To collection.Count
        Set doc = collection.GetNthDocument( i )
        Print #fileNum%, "Document nr. " & Cstr (i)
        j = 0
        Forall item In doc.items
            Redim Preserve arrValue(j)
            arrValue(j) = item.Name & ": " & item.text
            j = j + 1
        End Forall


Call Bubblesort(arrValue)


Forall value In arrValue
            Print #fileNum%, value
        End Forall
        Print #fileNum%, ""

End Sub

Sub BubbleSort(A As Variant)
    Dim I As Long, J As Long, Hi As Long
    Dim Temp As Variant
    Dim lb As Long
    Dim ub As Long

    lb = Lbound(A)
    ub = Ubound(A)


Hi = ub
            J = 0
            For i = lb + 1 To Hi
            If A(I - 1) > A(I) Then
                J = I - 1
                Temp = A(J)
                A(J) = A(I)
                A(I) = Temp
            End If
        Hi = J
    Loop Until J = 0
End Sub

This was first published in May 2001

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.