LOTUSSCRIPT /COM/OLE のクラス


例:BuildCollection メソッド
次のエージェントは現在のデータベース内のフォーム要素とビュー要素に基づく文書コレクションを作成します。この作成処理はサブルーチンによって行われます。サブルーチンは入力パラメータの値に従って文書コレクションをビルドし、その後コレクションを消去します。

Sub Initialize
Dim s As New NotesSession
Dim db As NotesDatabase
Set db = s.CurrentDatabase
Dim stream As NotesStream
Set stream = s.CreateStream
Dim nc As NotesNoteCollection
Set nc = db.CreateNoteCollection(False)

REM Export forms
Call ExportFormView(True, False, s, db, stream, nc)

REM Export views
Call ExportFormView(False, True, s, db, stream, nc)

REM Export forms and views
Call ExportFormView(True, True, s, db, stream, nc)

REM Test bad call
Call ExportFormView(False, False, s, db, stream, nc)
End Sub

Sub ExportFormView(form As Boolean, view As Boolean, _
session As NotesSession, db As NotesDatabase, _
stream As NotesStream, nc As NotesNoteCollection)

REM Check parameters and set up filename
If form And view Then
filename$ = "formview"
Elseif form Then
filename$ = "form"
Elseif view Then
filename$ = "view"
Else
Messagebox "Form and view both false",, "No action"
Exit Sub
End If

REM Open dxl file as stream
filename$ = "c:\dxl\" & filename$ & ".dxl"
If Not stream.Open(filename$) Then
Messagebox "Cannot open " & filename$,, "Error"
Exit Sub
End If
Call stream.Truncate

REM Create note collection
Call nc.SelectAllNotes(False)
If form Then
nc.SelectForms = True
nc.SelectSubforms = True
nc.SelectSharedFields = True
End If
If view Then
nc.SelectViews = True
nc.SelectFolders = True
End If
Call nc.BuildCollection

REM Export DXL
Dim exporter As NotesDXLExporter
Set exporter = session.CreateDXLExporter(nc, stream)
Call exporter.Process

REM Close stream and clear collection
Call stream.Close
Call nc.ClearCollection
End Sub

関連項目