Pages

Wednesday, December 1, 2010

Lotusscript code to export dxl of a database

Function exportDBDxl(sourceDB As NotesDatabase,targetFilePath As String) As Boolean
 '***********************************************************
 '@Purpose : To export the dxl of a database to the specified location
 '@Author   : Karthikeyan A
 '*********************************************************** 

'mark the flow of control getting inside the current function
exportDBDxl=False

'declare all variables and objects necessary for further manipulation
Dim session As New NotesSession
Dim db As NotesDatabase
Dim exporter As NotesDXLExporter
Dim opStream As NotesStream

'handle errors in case of abrupt termination
On Error Goto errHandler

'create a dxl exporter
Set exporter = session.CreateDXLExporter
'create a stream
Set opStream=session.CreateStream
'open the targetFilePath using the stream
Call opStream.Open(targetFilePath)
'export the contents on the current database to the stream (i.e. the target file path)
Call opstream.WriteText(exporter.Export(sourceDB))
'once the export is complete close the stream
Call opstream.Close

  'mark the flow of control moving out of  the current function
exportDBDxl=True
Exit Function
'display the errors that resulted in abrupt termination
errHandler:
Print "Error ***" & Error & " occured on line ***" & Cstr(Erl) & "*** with error number ***" & Cstr(Err)  & "*** while attempting to export dxl of specified database"
Msgbox "Error ***" & Error & " occured on line ***" & Cstr(Erl) & "*** with error number ***" & Cstr(Err)  & "*** while attempting to export dxl of specified database"
Exit Function
End Function


Hope this helps:)

No comments:

Post a Comment