For each document you process, after you have finished processing, you normally get the next document. So, we want to put in a doc.remove before we move on to the next document. The only problem is, once we remove the doc, we have no way of using the (now dearly departed) doc object to find the next doc. So, we briefly use a temp doc object, nextDoc, to get the next document BEFORE we delete the previous (current) one. Then, once we remove the current one, we assign the doc object, which is used everywhere, to the value of getNextDocument that was already pre-retrieved into nextDoc.

But you could get the same error as Hemantha's code gives... if the open document is part of the UnprocessedDocuments collection that you are processing.

So, please explain what's going on here. Since you are using UnprocessedDocumnts, I assuemd that this is in an agent. Are you calling the agent from a button or hotspot or action bar on a form? In that case, you shoudl close the document before running the agent. Otherwuse, can give you a workaround that will exclude the current document, but I still need info on exactly how the code is being called.

Yes, this is an agent. And, I am running it from the preview window which may account for the doc being open problem. I would like a workaround for this as I use the document preview all the time. Thanks.

In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication. Every Where from Works place to…

Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory.
NOTE: For Outlook 2016 and 2013 perform the exact same steps.
Open a new email: Click the New email button in Outlook.
Start typing the address: …