Function exportDocDxl(sourceDoc As NotesDocument,targetFilePath As String) As Boolean
'***********************************************************
'@Purpose : To export the dxl of a database to the specified document
'@Author : Karthikeyan A
'***********************************************************
'mark the flow of control getting inside the current function
exportDocDxl=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
If Not opStream.Open(targetFilePath) Then
Msgbox "Cannot open "& targetFilePath, , targetFilePath
Exit Function
End If
If opStream.Bytes <> 0 Then
Call opStream.Truncate
End If
'export the contents on the current database to the stream (i.e. the target file path)
Call opstream.WriteText(exporter.Export(sourceDoc))
'once the export is complete close the stream
Call opstream.Close
'mark the flow of control moving out of the current function
exportDocDxl=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 selected document"
Msgbox "Error ***" & Error & " occured on line ***" & Cstr(Erl) & "*** with error number ***" & Cstr(Err) & "*** while attempting to export dxl of selected document"
Exit Function
End Function
Hope this helps:)
No comments:
Post a Comment