Function CopyFolder( sourceDB As NotesDatabase, SourceName As String, DestDB As NotesDatabase, DestName As String) As Integer ' ========================================================================= ' Copies a folder (design) from source database into destination database ' Returns 0 if successful, any other value if not ' Note: This code might fail if source folder/design contains "special" characters like äöü ' ========================================================================= Dim session As New NotesSession Dim filename As String Dim view As NotesView Dim ExportNC As NotesNoteCollection Dim importer As NotesDXLImporter Dim exporter As NotesDXLExporter Dim dxl As String Dim doc As NotesDocument CopyFolder = -1 On Error Goto err1 ' ========================================== ' Perform some basic tests, return -1 if exit ' ========================================== If Not sourceDB.IsOpen Then Exit Function If Not DestDB.IsOpen Then Exit Function If SourceName="" Then Exit Function If DestName="" Then Exit Function ' ================================== ' get the source view return -2 if exit ' ================================== CopyFolder = -2 Set View = sourceDB.GetView( SourceName ) If view Is Nothing Then Exit Function ' ================================== ' Copy document to ExportNoteCollection ' ================================== Set ExportNC = sourcedb.CreateNoteCollection(False) Call ExportNC.add( view ) ' ================================== ' Export into a string ' ================================== Print "CopyFolder(): Create DXL from " & view.Name Set exporter = session.CreateDXLExporter DXL = exporter.Export( ExportNC) ' ================================== ' Modify DXL code (destination folder name) ' ================================== dxl = Replace( DXL, SourceName, DestName, 1, 10,5) ' ================================== ' Import ' ================================== Print "CopyFolder(): Create new folder " & DestName Set importer = session.CreateDXLImporter( DXL, DestDB ) importer.ReplaceDBProperties = False importer.DesignImportOption = DXLIMPORTOPTION_CREATE Call importer.Process ' ================================== ' Sign (optional) ' ================================== Set doc = destdb.GetDocumentByID( importer.GetFirstImportedNoteId ) Call doc.Sign Call doc.Save( True,False,False) CopyFolder = 0 Exit Function err1: CopyFolder = Err Print "CopyFolder(): " & Error$ & " in line " & Erl Messagebox "CopyFolder(): " & Error$ & " in line " & Erl Exit Function End Function