LOTUSSCRIPT /COM/OLE のクラス
Sub Click(Source As Button) Dim workspace As New NotesUIWorkspace Dim uidoc As NotesUIDocument Dim doc As NotesDocument Dim choice As String Set uidoc = workspace.CurrentDocument Set doc = uidoc.Document choice = Inputbox( "Please enter a folder name:", _ "Which folder?") Call doc.PutInFolder( choice ) Call PutAllResponsesInFolder( doc, choice ) End Sub
PutAllResponsesInFolder サブルーチンは親文書とフォルダ名を取得して、親文書の返答文書と返答の返答文書を指定されたフォルダに配置します。サブルーチンは、親文書への各返答文書を指定されたフォルダに配置します。サブルーチンはそれぞれの返答ごとに自分自身を呼び出し、各返答への返答文書もすべてフォルダに配置します。このような再帰的な動作により、ネストのレベルがどれほど深くても親文書のすべての子文書にアクセスできます。返答文書がなくなるとサブルーチンは終了します。
Sub PutAllResponsesInFolder _ ( doc As NotesDocument, folderName As String ) Dim collection As NotesDocumentCollection Dim currentResponse As NotesDocument Set collection = doc.Responses Set currentResponse = collection.GetFirstDocument ' Put immediate responses to doc into the folder ' If there are none, sub exits and returns to calling sub While Not ( currentResponse Is Nothing ) Call currentResponse.PutInFolder( folderName ) ' Recursive call to put immediate responses to ' currentResponse in folder Call PutAllResponsesInFolder _ ( currentResponse, folderName ) Set currentResponse = collection.GetNextDocument _ ( currentResponse ) Wend End Sub
関連項目