I have just added a new method to the DominoView class in the .Domino Framework that simulates the Edit\Copy Selected As Table functionality. Instead of pasting the table onto the clipboard the method accepts a RichTextItem and inserts the table at the end of that rich text item. In my case I am using this method to solve an application need for pasting selected rows into the body of an e-mail.
'/**
' * Copies the selected documents as a table inside a Rich text Item
' */
Sub CopySelectedAsTable(Item As NotesRichTextItem)
Dim Column As NotesViewColumn ' Specific column in view
Dim ColumnIndex As Integer ' Index of the column being processed
Dim Doc As NotesDocument ' Document being processed
Dim DocEntry As NotesViewEntry ' View entry for column being processed
Dim DocList As NotesDocumentCollection ' Selected documents
Dim RowIndex As Integer ' Row in table being processed
Dim RTNav As NotesRichTextNavigator ' Allows navigation within Rich Text Item containing table
Dim TableStyle As NotesRichTextParagraphStyle
Dim TableStyles() As NotesRichTextParagraphStyle ' Styles used to format table
Dim ViewNav As NotesViewNavigator ' Navigation of view
Try:
' On Error Goto Catch
If (IUIView Is Nothing) Then Exit Sub
Set DocList = iUIView.Documents
If (DocList.Count = 0) Then Exit Sub
' Create Empty Table using styles based upon view attributes
Redim TableStyles(Ubound(iView.Columns)+1)
Set TableStyles(0) = Session.CreateRichTextParagraphStyle()
TableStyles(0).LeftMargin = 0
TableStyles(0).FirstLineLeftMargin = 0
TableStyles(0).RightMargin = 125
For ColumnIndex% = 0 To Ubound(iView.Columns)
Set Column = iView.Columns(ColumnIndex%)
Set TableStyles(ColumnIndex%+1) = Session.CreateRichTextParagraphStyle()
TableStyles(ColumnIndex%+1).LeftMargin = 0
TableStyles(ColumnIndex%+1).FirstLineLeftMargin = 0
TableStyles(ColumnIndex%+1).RightMargin = Column.Width * 125
Next ColumnIndex%
Call Item.AppendTable(DocList.Count+1,Ubound(iView.Columns)+2,,RULER_ONE_INCH,TableStyles) ' Create empty table
Set RTNav = Item.CreateNavigator()
Set ViewNav = iView.CreateViewNav()
' Output view title to first row
For ColumnIndex% = 0 To Ubound(iView.Columns)
Call RTNav.FindNthElement(RTELEM_TYPE_TABLECELL,ColumnIndex%+2)
Set Column = iView.Columns(ColumnIndex%)
Call Item.BeginInsert(RTNav)
Call Item.AppendText(Column.Title)
Call Item.EndInsert()
Next ColumnIndex%
' Output Data
Set Doc = DocList.GetFirstDocument
RowIndex% = 1
While Not Doc Is Nothing
Call RTNav.FindNthElement(RTELEM_T