Examples: CreateCopy method

  1. This script creates an empty copy of the database PURCHASE.NSF on the server Athens.

    Dim db As NotesDatabase, archiveDb As NotesDatabase
    Set db = New NotesDatabase( "Athens","purchase.nsf" )
    Set archiveDb = db.CreateCopy _
    ( "Athens","archive\purchase.nsf" )
  2. This script archives all documents in the current database for which the age item equals "old". It calls CreateCopy only if the archive database does not exist yet. You can use the script before or after the archive database has been created.
    Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim archiveDb As NotesDatabase
    Dim collection As NotesDocumentCollection
    Dim doc As NotesDocument
    Set db = session.CurrentDatabase
    Set archiveDb = New NotesDatabase( "", "" )
    archiveServer$ = ""
    archiveFile$ = "archive\"+db.FileName
    If (Not(archiveDb.Open(archiveServer$, _
    archiveFile$))) Then
      Set archiveDb = db.CreateCopy( archiveServer$, _
      archiveFile$ )
    End If
    Set collection = db.AllDocuments
    Set doc = collection.GetFirstDocument()
    While Not(doc Is Nothing)
      Call doc.CopyToDatabase( archiveDb )
      Set doc = collection.GetNextDocument(doc)
    Wend