%REM Import DXL: Agent to import DXl elements into Lotus Notes without requiring Designer. Companion to Email Export agent, created to import MimeConvert form. Requires Lotus Notes 6.x or greater. Based upon Eitan Rosenberg's article of 12.15.2004: Using DXL (Domino XML) to review/modify documents http://searchdomino.techtarget.com/tip/0,289483,sid4_gci1034782,00.html Copyright 2008 Tech[niques] (http://tech.niques.info). Some rights reserved. This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 Australia License. See http://creativecommons.org/licenses/by-nc-sa/2.5/au/ for more details. Version 1.5 2008/02/11 Importer flexibility and error reporting improved. DXL to import no longer hard coded. Renamed Version 1.0 2008/02/10 Initial release Agent Properties box ==================== Name : Archive\(Custom) Import DXL Event to trigger agent : Action menu selection Selection Target : none %END REM Option Public Option Explicit Sub Initialize On Error Goto ErrorHandler Dim session As New NotesSession Dim database As NotesDatabase Dim filenames As Variant Dim filename As String Dim importer As NotesDXLImporter Dim ws As New notesuiworkspace Dim errorFileNum As Integer Dim errorFileName As String Set database = session.CurrentDatabase Dim stream As NotesStream Set stream = session.CreateStream filenames = ws.openfiledialog(False,"Select DXL file to import", "DXL/XML Files|*.dxl;*.xml|Text Files|*.txt|All Documents|*.*") If Isempty(filenames) Then Messagebox "Filename not specified",, "Error" Exit Sub End If filename = Cstr(filenames(0)) If filename = "" Or Not stream.Open(filename$) Then Messagebox "Filename not specified or cannot open: " & filename,, "Error" Exit Sub End If Set importer = session.CreateDXLImporter(stream,database) importer.DocumentImportOption = DXLIMPORTOPTION_REPLACE_ELSE_CREATE importer.DesignImportOption = DXLIMPORTOPTION_REPLACE_ELSE_CREATE importer.ReplicaRequiredForReplaceOrUpdate = False ' importer.InputValidationOption = VALIDATE_NEVER Call importer.Process Exit Sub ErrorHandler: Const LSI_THREAD_PROC = 1 Const LSI_THREAD_CALLPROC=10 Dim messageString As String messageString = Now & "-" & "Error in " & session.CurrentAgent.name & ". " & _ Getthreadinfo(LSI_THREAD_CALLPROC) & ", Erl()=" & Cstr(Erl()) & _ " ,Err()=" & Cstr(Err()) & " ,Error()=" & Error() If Err() = 4522 Then errorFileNum% = Freefile errorFileName$ = filename & ".log" Open errorFilename$ For Output As errorFileNum% Print #errorFileNum%, importer.log() Close errorFileNum% messageString = messageString & ". Additional details logged to: " & errorFileName End If Msgbox messageString End Sub