Examples: ClearCollection method
This form contains buttons for building a note collection, clearing it, and exporting it to DXL. If the user attempts to export without first building, or after clearing and not building again, an error occurs. The code traps this error.
%INCLUDE "lsxbeerr.lss"
Dim session As NotesSession
Dim db As NotesDatabase
Dim nc As NotesNoteCollection
Dim stream As NotesStream
Dim exporter As NotesDXLExporter
Sub Initialize
Set session = New NotesSession
Set db = session.CurrentDatabase
Set stream = session.CreateStream
Set nc = db.CreateNoteCollection(False)
nc.SelectDocuments = True
Set exporter = session.CreateDXLExporter(nc, stream)
End Sub
Sub Click(Source As Button)
Call nc.BuildCollection
End Sub
Sub Click(Source As Button)
Call nc.ClearCollection
End Sub
Sub Click(Source As Button)
On Error lsERR_NOTES_DXLEXPORTER_INPUT_OBJECT Goto handler
REM Open file as stream
If Not stream.Open("c:\dxl\documents.dxl") Then
Messagebox "Cannot open file",, "Error"
Exit Sub
End If
Call stream.Truncate
REM Export DXL
Call exporter.Process
REM Close stream
Call stream.Close
Exit Sub
handler:
Messagebox "Must build note collection",, _
"Note collection cleared"
Call stream.Close
Exit Sub
End Sub