Ropardo Sowftware development company

Experience software development with ROPARDO S.R.L.

RSS Feed
RSS Feed
  • Home
  • About ROPARDO S.R.L
  • Our websites

Generating word documents from Lotus Notes documents

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

  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
Get Shareaholic
Tags: Lotus Notes lotus script Lotus Symphony

 Posted in: Lotus Notes
January 15, 2010 | Ioan Seicean | No Comments

Leave a Reply

 


  • « Previous post
  • Next post »
  • Recent Posts

    • Installing PyGraphviz on Windows
    • Convert python object to XML representation
    • Liferay Portlet Development
    • Norway Road Show 2011 private meeting invitation
    • Oracle OpenWorld 2011
  • Ropardo is Hiring

  • Subscribe

    • Add to Google Reader or Homepage Add to netvibes TopOfBlogs
  • Recent Comments

    • Rajkumar Pomaji on Bluetooth PC Remote Control
    • Stelian Morariu on GWT 2.1 – Uploading a file using the RPC mechanism
    • Sergio on GWT 2.1 – Uploading a file using the RPC mechanism
    • Artem on Liferay: Deployment will start in a few seconds… and how to realy start
    • rkd80 on GWT 2.1 – Uploading a file using the RPC mechanism
  • Archives

    • November 2011 (1)
    • September 2011 (4)
    • July 2011 (3)
    • June 2011 (2)
    • May 2011 (4)
    • April 2011 (4)
    • March 2011 (3)
    • February 2011 (2)
    • January 2011 (2)
    • December 2010 (1)
    • November 2010 (4)
    • October 2010 (4)
    • August 2010 (3)
    • July 2010 (3)
    • June 2010 (6)
    • May 2010 (8)
    • April 2010 (7)
    • March 2010 (9)
    • February 2010 (6)
    • January 2010 (5)
    • December 2009 (7)
    • November 2009 (9)
    • October 2009 (10)
    • September 2009 (14)
    • August 2009 (10)
    • July 2009 (1)
    • June 2009 (1)
    • May 2009 (1)
    • April 2009 (1)
    • March 2009 (1)
    • October 2008 (3)
    • October 2007 (3)
    • July 2007 (4)
    • June 2007 (1)
    • May 2007 (3)
  • Meta

    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org
  • Categories

    • News (15)
    • Ropardo Team (8)
    • Ropardo Products (6)
      • File Tracking Client (4)
      • iManagement (2)
    • Software Development (83)
      • Microsoft.NET (22)
      • Java (40)
      • Oracle (8)
      • Power Builder (3)
      • Liferay (5)
      • Lotus Notes (9)
      • xWiki (4)
    • System Adminstration (13)
      • Linux (10)
      • Windows (3)
    • Programming (1)
    • Uncategorized (3)
    • Databases (10)
      • MSSQL (5)
      • PostgreeSQL (3)
    • Microsoft.NET (1)
    • Web Development (28)
      • ASP/ASPX (3)
      • Content Management Systems (1)
      • HTML/CSS (5)
      • Javascrip/AJAX (8)
      • PHP (7)
    • Oracle E Business Suite (6)
  • Tags

    .NET ajax blog C# certification client CMS control css database Debugging django Domino Eclipse extension file tracking filter fun gentoo google Hibernate how to html image iManagement import Java javascript jQuery liferay Linux Lotus Notes lotus script Oracle Oracle BI Publisher 11g PHP portal PostgreSQL powerbuilder Python SQL Telerik velocity xml Xwiki

© 2010 ROPARDO s.r.l..

Powered by WordPress. Styled by Ropardo