Ignore the corrupted document

Hello All, I have a database from where I am exporting the document as a .CSV file.

Now I want to handle one situation When ever any corrupted document found during the export. Code ignore the corrupted document and go to the next doc.

Exp:- If 10 documents are there from 1 to 7 document is ok 8th document is corrupted so code should ignore the 8th doc and export the 9th and 10th. I am already handling the ERROR by On Error Resume Next.

How to handle the corrupted document in code. Please suggest.

Subject: Ignore the corrupted document.

How do you know a document is corrupted?If you know, then you can check for it in the code and exclude it in the loop.

The other way is to handle the errors in a smarter way.

Resume Next is not the best option, you won’t really know if you had an error or not by using that.

Try this (I’m assuming you have a NotesDocumentCollection:

Sub yourSub

Dim …

Dim strDebug As String

Dim strMsg As String

On Error GoTo errHandler

strDebug = “”

Set doc = dc.GetFirstDocument

While Not (doc Is Nothing)

strDebug = “Processing”

— process document here—

strDebug = “”

'-- Paragraph to resume to after errors.

goGetNext:

Set doc = dc.GetNextDocument(doc)

Wend

bailOut:

Exit Sub

errHandler:

Select Case strDebug

Case “Processing”

Resume goGetNext

Case Else

'-- This is some other error, not in the document processing.

strMsg = “We had an error.” & chr(10)

strMsg = strMsg & "Error code: " & Cstr(Err()) & Chr(10)

strMsg = strMsg & "Error text: " & Error$ & Chr(10)

strMsg = strMsg & "Error line: & Cstr(Erl())

MessageBox strMsg, 16, “Error”

Resume bailOut

End Select

End Sub

This way you can handle all errors and treat the ones you know has to do with corrupted documents so that you just skip them and get the next document in the collection.