Copy or Move Documents

Lotus Domino
Hi I need to copy or move set of documents from one nsf database to another nsf database at a stretch using lotus script method.As we do stampall for notescollection class. Thanks

Answer Wiki

Thanks. We'll let you know when a new response is added.

Here is a method that can be tailored to your specific needs:

Sub transferDocuments(MoveDocuments As Variant) ‘MoveDocuments: True -> Move, False -> Copy
‘This example will process all of the documents in a given view. You can be more specific if you need to be.
Dim lSession As NotesSession
Dim lTargetDB As NotesDatabase
Dim lSourceView As NotesView
Dim lDoc As NotesDocument
Dim lTempDoc As NotesDocument
Dim lTargetDBServer As String
Dim lTargetDBPath As String
Dim lSourceViewName As String

On Error Goto ErrorHandler

lTargetDBServer = Inputbox(“Enter the name of the target database server.”)
lTargetDBPath = Inputbox(“Enter the path of the target database.”)
lSourceViewName = Inputbox(“Enter the name (or alias) of the source view.”)

‘Connect to the target database
Set lTargetDB = New NotesDatabase(“”,””)
Call lTargetDB.Open(lTargetDBServer, lTargetDBPath)

‘Get a reference to the source view by getting a reference to the current database via the session object
Set lSession = New NotesSession
Set lSourceView = lSession.CurrentDatabase.GetView(lSourceViewName)

‘Start with the first document in the view
Set lDoc = lSourceView.GetFirstDocument
‘Visual feedback – shows up in the status bar.
Print “Processing document ” & lDoc.NoteID

‘Copy the document to the target database
Set lTempDoc = lDoc.CopyToDatabase(lTargetDB)

‘Get a copy of the local document
Set lTempDoc = lDoc

‘Get a reference to the next document to copy from the source view
Set lDoc = lSourceView.GetNextDocument(lDoc)

If MoveDocuments Then
‘Remove the document from the current database
Call lTempDoc.Remove(False)
Call lSourceView.Refresh
End If
Loop Until lDoc Is Nothing

Print “Document transfer complete!”


If lTargetDB.isOpen Then
Call lTargetDB.Close
End If

Set lTempDoc = Nothing
Set lDoc = Nothing
Set lSourceView = Nothing
Set lTargetDB = Nothing
Set lSession = Nothing

Exit Sub

Messagebox “Error: ” & Err & Chr(10) & Error & ” occurred on line ” & Erl,, “Error transferring document between databases”
Resume ExitHere
End Sub

Discuss This Question: 1  Reply

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • KavithaRao
    I dont want loop all the documents for coping a documents to another db. This has to done within one statment. As I mentioned already the method like stampall in notes document collection class. Hope you are getting my requirement. Anyway thanks Charles my requirement should not loop the document collection. Thanks
    0 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: