Dim s As New NotesSession Dim db As NotesDatabase ' current db Dim vUI As NotesUIView ' current view Dim dc As NotesDocumentCollection ' documents selected in view Dim dcDoc As NotesDocument ' single doc selected, or current doc in dc Dim dccount As Long ' number of docs processed On Error Goto ErrorHandler ' set up environment Set db = s.CurrentDatabase Set vUI = w.CurrentView ' verify view exists If (vUI Is Nothing) Then ' no view currently open, abort Print "No current view. Aborted." Msgbox "Not in a view. Aborting run.", , "Aborted" Exit Sub End If ' get selected docs Set dc = vUI.Documents Set dcDoc = dc.GetFirstDocument() If Not (dcDoc Is Nothing) Then ' multiple docs selected to process dccount = dc.Count Else ' no document selected, however one is probably highlighted, get it Set dcDoc = db.GetDocumentByID(vUI.CaretNoteID) If Not (dcDoc Is Nothing) Then ' add doc to collection newssearchstr = {Form = "asdfasdf12535asdf" } ' bogus search just to get empty collection Set dc = db .Search( newssearchstr , Nothing , 1 ) If (dc.Count > 0) Then ' error, search should not return anything Print "Cancelled. Unexpected error creating collection to forward." Exit Sub End If ' add the current doc to collection Call dc.AddDocument(dcDoc) If Not (dc.Count = 1) Then ' error, collection should now contain the current doc Print "Cancelled: Current document could not be added to collection for forwarding." Exit Sub End If dccount = dc.Count Else ' tried all and no doc was selected Print "No docs selected. Cancelled." Msgbox "No docs selected.", , "Cancelled" Exit Sub End If End If ' made all the checks, have at least one document to process Print "Processing " & Cstr(dccount) & " documents . . . " ... rest of code to process the documents in the counter ... ' done Print "Processed " & Cstr(dccount) & " documents. See above log lines for any errors. Done." Exit Sub ErrorHandler: Print "(Initialize) Unexpected Error: " & Cstr(Err) & ", " & Error$ & ", on line: " & Cstr(Erl) & "." Exit Sub