I have a view full of about 40 documents. I want to loop through them an open/edit/save each one so that a QuerySave action happens that does a bunch of other stuff.
I built the following code which generates an error that I believe is caused by the line
Call UserUIDocument.Close
If I REM out that line everything works but I end up with all the documents open.
The error is “Error 4429: Unable to defer document close”
any ideas?
==========================================
Sub Initialize
Dim Session As New NotesSession
Dim DB As NotesDatabase
Dim NoteCollection As NotesDocumentCollection
Dim UserUIDocument As NotesUIDocument
Dim UserUIWorkspace As New NotesUIWorkspace
Dim dateTime As New NotesDateTime( "12/01/94" )
Dim NoteDoc As NotesDocument
On Error Goto HandleErr
Set DB = Session.CurrentDatabase
searchFormula$ = "Form = ""Category"""
Set NoteCollection = DB.Search( searchFormula$, dateTime, 0)
Set NoteDoc = NoteCollection.GetFirstDocument
For i = 1 To NoteCollection.Count
Set UserUIDocument = UserUIWorkspace.EditDocument( True, NoteDoc)
Call UserUIDocument.Save
Call UserUIDocument.Close
Set NoteDoc = NoteCollection.GetNextDocument(NoteDoc)
Next
Msgbox "This agent has worked with " & NoteCollection.Count & " Notes." & Error, 0 + 48, "System Message"
Exit Sub
’ Error Handling
HandleErr:
Msgbox "Unknown error:" & Chr(10) & Chr(10) & "Error Num: " & Err() & Chr(10) & "Description: " & Error, 0 + 48, "System Message"
Exit Sub ' Exit when error occurs
End Sub