Generating word documents from Lotus Notes documents

Share

Sometimes you wish to print the information contained in a Lotus Notes document. Lotus Notes offers such printing options, but if you have layout issues one solution would be to export into an word document.

You can create an word document in Lotus Script using CreateObject(“Word.Application”) function. It only works on your computer if you have Microsoft Word installed. Luckily Lotus Notes comes with an alternative, Lotus Symphony.

Lotus Symphony is a set of applications for creating, editing word processing documents, spreadsheets, and presentations. The Lotus Symphony Object Model provides APIs to control Lotus Symphony, such as opening documents, presentations and spreadsheets or manipulating tables, paragraphs, sections of a document.

In order to export the Lotus Notes document we will need an template document. This template document contains bookmarks acting as tags for writing information. I had trouble working with .doc format so instead of using this format, I have converted into an .odt format. The template document is opened in invisible mode by setting the second parameter of the OpenDocument method to False.

Dim symphony As New SymphonyApplication
Dim templateDocument As SymphonyDocument
Dim newDocument As Symphonydocument
Set templateDocument = symphony.Documents.OpenDocument("C:\template.odt", False)
Set newDocument = symphony.Documents.AddDocument()
newDocument.Selection.Range.Importfile(templateDocument.FullName)
templateDocument.Closedocument(False)
Call SetBookmarks(doc, formatdoc, uidoc, newDocument)

All the content of the template.doc is copied into a new document. After that the bookmarks for name and address are set using SetBookmark subrutine.

Sub SetBookmark(bookmarkName As String, bookmarkText As String , document As SymphonyDocument)
	Sub SetBookmark(bookmarkName As String, bookmarkText As String , document As SymphonyDocument)
	Dim i As Long
	Dim bookmark As Symphonybookmark
	For i = 1 To document.Bookmarks.count
		If document.Bookmarks.Item(i).Name = bookmarkName Then
			Set bookmark = document.Bookmarks.Item(i)
			bookmark.Range.Text = bookmarkText
			Exit For
		End If
	Next
End Sub

Rich text items from the Lotus Notes document are treated a bit different.

Sub SetBookmarkFromRichTextItem(bookmarkName As String, fieldName As String, uidoc As NotesUIDocument, document As SymphonyDocument)
	Dim i As Long
	Dim bookmark As Symphonybookmark
	Dim doc As NotesDocument
	Set doc = uidoc.Document
	Dim item As NotesRichTextItem
	Set item = doc.GetFirstItem(fieldName)
	If Not (item Is Nothing ) Then
		If item.text <> "" Then
			Call uidoc.GotoField(fieldName)
			Call uidoc.Selectall
			Call uidoc.Copy
			Call SetBookmarks(bookmarkName, uidoc.Getselectedtext(fieldName), document)
		End If
	End If
End Sub

We can than select a region in the document delimited by two bookmarks and format the size and height of the font.

Sub SetFont(startBookmarkName As String, endBookmarkName As String, document As Symphonydocument, fontName As String, fontHeight As String)
	Dim i As Long
	Dim bookmark As Symphonybookmark
	Dim bookmark2 As Symphonybookmark
	Dim selection As SymphonyDocumentSelection
	Set selection = document.Selection
	For i = 1 To document.Bookmarks.count
		If document.Bookmarks.Item(i).Name = startBookmarkName Then
			Set bookmark = document.Bookmarks.Item(i)
		End If
		If document.Bookmarks.Item(i).Name = endBookmarkName Then
			Set bookmark2 = document.Bookmarks.Item(i)
		End If
	Next
	Call selection.Setrange(bookmark.Range, bookmark2.Range)
	selection.Range.Font.Name = fontName
	selection.Range.Font.Height = fontHeight
End Sub
Sub SetBookmarks(doc As NotesDocument, formatdoc As NotesDocument, uidoc As NotesUIDocument, templateDocument As SymphonyDocument)
If templateDocument.Bookmarks.Exists("name") = True Then
	Call SetBookmark("name", doc.name(0), templateDocument)
End If
If templateDocument.Bookmarks.Exists("address") = True Then
	Call SetBookmark("address", doc.address(0), templateDocument)
End If
If templateDocument.Bookmarks.Exists("body") = True Then
	Call SetBookmarkFromRichTextItem("body", "Body", uidoc, templateDocument)
End If
If templateDocument.Bookmarks.Exists("begin") = True And templateDocument.Bookmarks.Exists("end") Then
	Call SetFont("begin", "end", templateDocument, formatdoc.WordFormFont(0), formatdoc.WordFormSize(0))
End If
Call templateDocument.Saveasdocument("C:\new_brief.doc",SYMPHONY_FILE_FORMAT_DOC )
End Sub

Finally the document is saved under .doc format.

References:
Lotus Symphony Home Page

Finally, there’s another very important peculiarity of what does Cialis that brings it so high above its alternatives. It is the only med that is available in two versions – one intended for use on as-needed basis and one intended for daily use. As you might know, Viagra and Levitra only come in the latter of these two forms and should be consumed shortly before expected sexual activity to ensure best effect. Daily Cialis, in its turn, contains low doses of Tadalafil, which allows to build its concentration up in your system gradually over time and maintain it on acceptable levels, which, consequently, makes it possible for you to enjoy sex at any moment without having to time it.

By continuing to use the site, you agree to the use of cookies. More information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close