Extract text from a rich text field

The formula and LotusScript below can be used to extract text from a RichText field.
Lotus Formula • Lotus Notes Form • LotusScript

FORMULA: (Insert the code into a computed text field on the form with the rich text field. Note: Rich Text fields only contain data once the doc is saved.)

@Abstract( [TextOnly] ;90 ;"" ; "Description_WebEntry" )






LOTUSSCRIPT: (Populates the text into a specified text field on the same document. It will overlook any attachments or images placed in the RichText field without producing an error.)

Sub Initialize
	
	Dim session As New NotesSession
	Dim workspace As New NotesUIWorkspace
	Dim db As NotesDatabase
	Set db = session.CurrentDatabase
	Dim collect As NotesDocumentCollection
	Set collect = db.UnprocessedDocuments
	
	If collect.count = 0 Then
		Msgbox " No Document(s) selected!", 0 + 16
		Exit Sub
	End If
	
	Dim rtitem As Variant
	Dim plainText As String
	Dim TargetItem As NotesItem
	
	Dim Doc As NotesDocument
	Set Doc = collect.GetFirstDocument
	
	Dim counter As Long
	
	Do		
		Set rtitem = doc.GetFirstItem( "Body" )
		
		If Not rtitem Is Nothing Then
			If ( rtitem.Type = RICHTEXT ) Then
				plainText = rtitem.GetFormattedText( False, 0 )
			End If
			Set TargetItem = doc.ReplaceItemValue( "Comments", plainText )
			Call doc.Save(True, True)
		End If
		
		Counter = Counter + 1
		Print Counter & " of " & collect.count & " have been processed."
		Set doc = collect.GetNextDocument(doc)
	Loop Until doc Is Nothing
	
	Call workspace.viewrefresh     
	
	Print "Process has completed"
	
End Sub

Posted by fbrefere001 on Wednesday April 3, 2002