Examples: Locating a document by ID in LotusScript® classes

This example stores the note ID of each document in a database in a string array, then uses the array in a loop of GetDocumentByID methods to access each document. You can substitute the UniversalID property and GetDocumentByUNID method in the example to use the universal ID.

Sub Initialize
  Dim session As New NotesSession
  Dim db As NotesDatabase
  Dim noteIDs()
  Dim collection As NotesDocumentCollection
  Dim doc As NotesDocument
  Set db = session.CurrentDatabase
  Set collection = db.AllDocuments
  Redim noteIDs(1 To collection.Count)
  Set doc = collection.GetFirstDocument()
  Messagebox "count = " & collection.Count
  If collection.Count > 0 Then
    For j = 1 To collection.Count
      noteIDs(j) = doc.noteID
      Set doc = collection.GetNextDocument(doc)
    Next
    Forall noteID In noteIDs
      Set doc = db.GetDocumentByID(noteID)
      Messagebox doc.Subject(0)
    End Forall
  End If
End Sub