UpdateProcessedDoc and UpdateAll not working

I am trying to process new documents using UnprocessedDocuments collection. The UpdateProcessedDoc and UpdateAll methods do not appear to work

For test purposes I have pared the agent down to this:

Sub x

Dim session As New NotesSession

Dim db As NotesDatabase

Dim collection As NotesDocumentCollection

Dim doc As NotesDocument



Set db = session.CurrentDatabase

Set collection = db.UnprocessedDocuments

Messagebox collection.Count	



Set doc = collection.GetFirstDocument()

While Not(doc Is Nothing)

   Call session.UpdateProcessedDoc( doc )

   Set doc = collection.GetNextDocument(doc)

Wend

’ I have also tried the following line (instead of the 5 lines above)

’ Call Collection.UpdateAll

End Sub

No matter how I run the agent (or how many times) I get the total number of docs in the db returned.

What am I doing wrong?

Subject: UpdateProcessedDoc and UpdateAll not working

What trigger are you using for your agent?

Subject: RE: UpdateProcessedDoc and UpdateAll not working

I have tried: After documents are created or modified

Running manually (Action menu selection) with Targets of:

All documents in DB

None

All with no luck