0 pts.
 Copy or Move Documents
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

Software/Hardware used:
ASKED: January 23, 2006  5:22 AM
UPDATED: January 24, 2006  11:52 PM

Answer Wiki:
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 Do '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!" ExitHere: 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 ErrorHandler: Messagebox "Error: " & Err & Chr(10) & Error & " occurred on line " & Erl,, "Error transferring document between databases" Resume ExitHere End Sub
Last Wiki Answer Submitted:  January 24, 2006  4:32 pm  by  CharlesJC   0 pts.
All Answer Wiki Contributors:  CharlesJC   0 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

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 pts.