Sub pasteWithUNID(targetDB As NotesDatabase)



Sub pasteWithUNID(targetDB As NotesDatabase)

'** This subroutine will paste the contents of the clipboard into the target database,

'** maintaining the Universal IDs and replacing any existing documents there may be.

Dim clipboard As New NotesDatabase("", "~clipbrd.ncf")

Dim dc As NotesDocumentCollection

Dim doc As NotesDocument, clipdoc As NotesDocument

'** Compile useful statistics **'

Dim uc As Integer, ac As Integer

On Error 4091 Resume Next '* Ignore "bad unid" errors *

If clipboard.isOpen() Then

Set dc = clipboard.allDocuments

Set clipdoc = dc.getFirstDocument

While Not clipdoc Is Nothing

'** Check for an existing document with the same unid. If it exists, replace its contents.

Set doc = Nothing

Set doc = targetDB.getDocumentByUNID(clipdoc.universalID)

If doc Is Nothing Then

ac = ac + 1

Else

doc.remove True

uc = uc + 1

End If

Set doc = New NotesDocument(targetDB)

clipdoc.copyAllItems doc, True

doc.universalID = clipdoc.universalID

doc.save True, False, True

Set clipdoc = dc.getNextDocument(clipdoc)

Wend

If ac + uc = 0 Then

Print "Nothing to Do. Please select and copy the documents first."

Else

Print "Done import: " & ac & " additions, " & uc & " updates."

End If

Else

Error 1, "Could not open the clipboard. Please select and copy the documents first."

End If

End Sub

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download