Home > Domino Tips > Developer > LotusScript > Retrieve cell values from tables in a Lotus Notes rich-text field
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

LOTUSSCRIPT

Retrieve cell values from tables in a Lotus Notes rich-text field


manikandan.sv@tcs.com
03.25.2008
Rating: -3.00- (out of 5)


Lotus Notes, Domino, Workplace and WebSphere tips and advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


Related resources from SearchDomino.com:
Tip: Create a table in a rich-text field

Expert Advice: Retrieve the values from a view column

Tutorial: 30 LotusScript tips

LotusScript Learning Guide

LotusScript Reference Center

Developers sometimes need to retrieve cell values within a table in a Lotus Notes rich-text field (RTF). The following LotusScript code will display the values in each cell within the body of any Lotus Notes mail document.

GetElementCount is used to count different types of RichTextItems in a field. This example uses the Table type.

Sub Initialize
Dim ws As New NotesUIWorkspace
Dim s As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim maildoc As NotesDocument
Dim rtitem As NotesRichTextItem
Dim rtnav As NotesRichTextNavigator


Set db=s.CurrentDatabase
Set dc=db.UnprocessedDocuments

If dc.Count>1 Then
Msgbox "Please select a single document", MB_OK, 
"Travel HelpDesk"
Continue=False
End
 Else
Set maildoc=dc.GetFirstDocument()
Set rtitem=maildoc.GetFirstItem("Body")
Set rtnav=rtitem.CreateNavigator
count = GetElementCount(rtnav, RTELEM_TYPE_TABLE)
'msg$ = msg$ & "Tables:" & Chr(9)  & Chr(9) & count% & Chr(10)
'Messagebox msg$,, maildoc.Subject(0)
If count=0 Then
Messagebox "Body item does not contain a table,",, _
"Error"
Exit Sub
End If
 
For k=1 To count
If  rtnav.FindNthElement(RTELEM_TYPE_TABLE,k) Then
Dim rttab As NotesRichTextTable
Set rttab=rtnav.GetElement
Dim rtrange As NotesRichTextRange
Set rtrange=rtitem.CreateRange
If k=1 Then
Call rtnav.FindFirstElement(RTELEM_TYPE_TABLECELL)    
Else
Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)
End If
    
firstFlag = True
 
For i& = 1 To rttab.RowCount
For j& = 1 To rttab.ColumnCount
If Not firstFlag Then
Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)
 Else     
  firstFlag = False       
End If
Call rtrange.SetBegin(rtnav)
Messagebox rtrange.TextParagraph,, _
 "Row " & i& & _
", Column " & j&
  Next     
 Next
End If
 Next
 End If
 
End Sub

Function GetElementCount(rtnav As NotesRichTextNavigator, 
eType As Integer) As Integer
 GetElementCount = 0
 If rtnav.FindFirstElement(eType) Then
  Do
GetElementCount = GetElementCount + 1
Loop While rtnav.FindNextElement()
 End If
End Function

Do you have comments on this tip? Let us know.

This tip was submitted to the SearchDomino.com tip library by member Manikandan.sv. Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.

Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED CONTENT
LotusScript
Launch large attachments within an email from a Notes database
How to find files on a hard drive or mapped network with LotusScript
Update the ACL from the Roles view with LotusScript
LotusScript agent moves tagged spam email to junk mail folder
Create a personalized greeting for Lotus Notes database users
Fail-safe rich-text validation using LotusScript
How to export Lotus Notes views to a Microsoft Excel database
Create file system labels for Microsoft Excel and Word mail merges
Fix Lotus Notes 8.0 issues when launching Microsoft Office applications
Capture rich-text comments in Lotus Notes fields using LotusScript

LotusScript
Launch large attachments within an email from a Notes database
How to find files on a hard drive or mapped network with LotusScript
Update the ACL from the Roles view with LotusScript
LotusScript agent moves tagged spam email to junk mail folder
Set a value in a field existing in another Lotus Notes database
Create an automatic scheduled view export in Excel
Top 10 LotusScript tips
Create a personalized greeting for Lotus Notes database users
Fail-safe rich-text validation using LotusScript
How to export Lotus Notes views to a Microsoft Excel database

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.

HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 1999 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts