Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim found As Variant
Set db = session.CurrentDatabase
Set view = db.GetView( "By Category" )
found = False
Forall c In view.Columns
If c.IsResponse Then
found = True
Exit Forall
End If
End Forall
If found Then
Messagebox _
( "There's at least one responses-only column." )
Else
Messagebox( "There are no responses-only columns." )
End If
End Sub
前提条件
Sub Initialize
Dim db As New NotesDatabase( "", "corn.nsf" )
Dim view As NotesView
Dim responsePos As Integer
Dim doc As NotesDocument
Dim rtitem As Variant
Dim response As NotesDocument
Dim tempResponse As NotesDocument
Set view = db.GetView( "All" )
' find the position of the Responses-only column
Forall c In view.Columns
If c.IsResponse Then
responsePos = c.Position
End If
End Forall
Set doc = view.GetFirstDocument
' visit each main document in the view
While Not( doc Is Nothing )
Set rtitem = doc.GetFirstItem( "Body" )
Set response = view.GetChild( doc )
' visit each response to the main document
While Not( response Is Nothing )
' fold the response's column value into the parent
Call rtitem.AppendText _
( response.ColumnValues( responsePos - 1 ) )
Call rtitem.AddNewLine( 1 )
' save a temporary copy of current response...
Set tempResponse = response
' ...so that the script can get the next response...
Set response = view.GetNextSibling( response )
'...and then delete the current response.
Call tempResponse.Remove( True )
Call view.Refresh
Wend
Call doc.Save( True, True )
Set doc = view.GetNextSibling( doc )
Wend
End Sub
例えば、[All] ビューが主要文書 1 つと返答文書 3 つを含む場合を考えます。各返答文書の件名と作成者が、返答専用の列に次のように表示されているものとします。
好きな色は?(Shelley Kinnamon) 青 (Joe Doyle) 紫 (Peg Yip) オレンジ (Kendra Zowker)
このスクリプトでは 3 つの返答文書を削除して、データベースに主要文書だけが残るようにします。
好きな色は?(Shelley Kinnamon)
主要文書の [本文] フィールドには次の文字列が含まれます。
青 (Joe Doyle) 紫 (Peg Yip) オレンジ (Kendra Zowker)