When database not contains a document with UNID by GetDocumentByKey an error?

if database contains a document with unid,it to continue next loops,but if database not contains a document with unid,it will be error.

the error code is:

line “(Set mdoc = mdb.GetDocumentByUNID(unidstr))” error:user defined error.

how to continue forall loops when database not contains a document with unid?

source code:

Dim session As New NotesSession

Dim mdb As NotesDatabase

Dim mdoc As NotesDocument



Dim unidstr(2) As String

Dim vara As Variant



unidstr(0) = "EEC1F0100C97ABAC482577120007A6F3"

unidstr(1) = "12C590C0F2A4CF74482575F600282391"

unidstr(2) = "594A2C1BE8863175482575F60029DAEE"



vara = unidstr



Set mdb = session.CurrentDatabase



Forall x In vara

	Set mdoc = mdb.GetDocumentByUNID(x)

	

	If Not(mdoc Is Nothing) Then

		Call mdoc.Remove(True)

	End If

End Forall

Subject: invalid universal ID

On Error 4091 Resume Next ’ need this to handle Invalid Universal ID errorSet mdoc = mdb.GetDocumentByUNID(x)