When you copy + paste a table or other contents from a NotesRichtextItem to Excel using LotusScript, the formatting mostly will get lost. There is a workaround to keep all the formatting and display your content in Excel just the way it appears in your NotesRichtextItem:
Copy+paste the content to Word first, copy it again to the clipboard, then close Word and paste the content of your clipboard to Excel. Works excellent.
Here is a sample code (assumes that you have an editable NotesRichtextItem "Body" on your document [with content in it] and a button that triggers the following code):
Sub Click(Source As Button)
' copy rt content
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = ws.CurrentDocument
Call uidoc.GotoField("Body")
Call uidoc.SelectAll
Call uidoc.Copy
' open word, paste and copy again
' (if we would paste to Excel directly, formatting would be lost)
Dim objWord As Variant
Set objWord = CreateObject("Word.Application")
Call objWord.Documents.Add()
Call objWord.Selection.Paste()
Call objWord.Selection.WholeStory()
Call objWord.Selection.Copy()
objWord.DisplayAlerts = False
Call objWord.quit(False)
' open excel and paste
Dim objExcel As Variant
Set objExcel = Nothing
Set objExcel = CreateObject("Excel.Application")
Call objExcel.Workbooks.Add()
Call objExcel.ActiveSheet.Paste()
objExcel.visible = True
End Sub
About the AuthorMarcus Foerster works as Systems Architect for Pentos AG in Munich,
Germany. His focus lies on the application side, creating collaboration
systems for users, groups and enterprises to get their daily work done.
This approach includes integrating complex workflows with intuitive
user interfaces, using Lotus Notes/Domino with Adobe Flex and other Web
technologies.
Read more in Marcus' blog: http://marcus.foerster.com/blog