RTF的使用

1、替换RTF域中的回车换行符

Replace(Replace(funrtf.GetUnformattedText,Chr(13),""),Chr(10),"")

2RTF用法

Dim rtfReader As Variant

Set rtfReader = doc.GetFirstItem("ReadersID")

If Instr(rtfReader.Text,user.ID)=0 Then

Call rtfSign.AppendText(tempStr)

Call rtfSign.AddNewLine( 1 )

Call doc.Save(True,False)

3、代理创建RTF

Dim bodyrtf As  NotesRichTextItem

Set bodyrtf = New notesRichTextItem(tardoc, "body")

Call bodyrtf.AppendText(doc.content(0))

4、代理获取RTF域中的值

Dim rtf As NotesRichTextItem

Set rtf = tardoc.GetFirstItem( "body" )

doc.content=rtf.GetUnformattedText

 

4dim rtitem As NotesRichTextItem

Set rtitem = doc.GetFirstItem( "Body" )

If ( rtitem.Type = RICHTEXT ) Then

  plainText = rtitem.GetFormattedText( False, 0 )

Call rtitem.AppendText(tempStr)

End If

5

Dim rtf As NotesRichTextItem

Set rtf = tardoc.GetFirstItem( "body" )

doc.content=rtf.GetUnformattedText

 

6. This script gets the Body item in a document, and writes its contents to a plain text file called PLANE.TXT. Any existing text in the file is written over. The text keeps its tabs and the default line wrapping is used.

Dim doc As NotesDocument

Dim rtitem As Variant

Dim plainText As String

Dim fileNum As Integer

'...set value of doc...

Set rtitem = doc.GetFirstItem( "Body" )

If ( rtitem.Type = RICHTEXT ) Then

  plainText = rtitem.GetFormattedText( False, 0 )

End If

' get a file number for the file

fileNum = Freefile

' open the file for writing

Open "c:\plane.txt" For Output As fileNum

' write the formatted text to the file

Print #fileNum, plainText

' close the file

Close #fileNum

  7. This script gets the Body item in a document, and appends its contents to a plain text file called .PLANE.TXT Any existing text in the file remains. The appended text is stripped of tabs and wraps every 15 characters.

Dim doc As NotesDocument

Dim rtitem As Variant

Dim plainText As String

Dim fileNum As Integer

'...set value of doc...

Set rtitem = doc.GetFirstItem( "Body" )

If ( rtitem.Type = RICHTEXT ) Then

  plainText = rtitem.GetFormattedText( True, 15 )

End If

' get a file number for the file

fileNum = Freefile

' open the file for appending

Open "c:\plane.txt" For Append As fileNum

' write the formatted text to the file

Print #fileNum, plainText

' close the file

Close #fileNum

8、判断RTF域是否为空

由于RTF域中可以输入多种信息(文本、附件、直接粘贴的图片、链接等),所以在验证该RTF域是否为空的时候会很麻烦,下面提供一种简便的方法。可以完整的验证RTF域中是否有值。Function IsRTFNull(uidoc As NotesUIDocument , rtf As String) As Integer

 '该函数必须在前台文档已经保存后才能生效!

 call uidoc.save

 Dim doc As NotesDocument

 Set doc = uidoc.Document

 

 IsRTFNull = False

 Dim rtitem As Variant

 Set rtitem = doc.GetFirstItem(rtf)

 

 If rtitem.type <> RICHTEXT Then 

  If rtitem.text = "" Then

   IsRTFNull = True

   Exit Function   

  End If  

 Else

  If rtitem.ValueLength <= 102 Then

   '102是一个空的RTF域所占的字节数,这个值可能会因为RTF域的隐藏属性、

               'RTF域是否在表格中等因素的不同而不同,所以在使用的时候一定要先确定

               '你的文档中一个空的RTF所占的字节数用来替换这里的数值(获取方法参见下图)

   IsRTFNull = True

   Exit Function

  End If

 End If 

End Function

9、公式显示RTF域中的值

@ReplaceSubstring(@Text(Body);@NewLine;"")

10、注:rtf无法在视图中显示,也无法使用@DBLOOKUP

11、@Contains(@Text(ReadersID);CurUserID)   ReadersID是rtf域

12、替换RTF域中的值

On Error Goto errhandler

Dim session As New NotesSession

Dim doc As NotesDocument

Dim maindoc As NotesDocument

Dim db As NotesDatabase

Dim item As NotesItem

Dim user As SUser

Dim sendmsg As New SMessage

Dim searchstr As String

Dim searchdocs As NotesDocumentCollection

Dim searchdoc As NotesDocument

Dim rtfitem As NotesRichTextItem

Dim temprtf As NotesRichTextItem

Set doc = session.DocumentContext

Set db = session.CurrentDatabase

Set maindoc = db.GetDocumentByUNID(doc.ParID(0))

If Not maindoc Is Nothing Then

'更新主文档信息

Set rtfitem=maindoc.GetFirstItem("ReadersID")

If maindoc.Hasitem("temprtf"Then

maindoc.Removeitem("temprtf")

End If

Set temprtf= maindoc.Createrichtextitem("temprtf")

 If InStr(rtfitem.GetFormattedText(False,0),doc.UserID(0)+";")<>0 Then

Call temprtf.Appendtext(Replace(rtfitem.GetFormattedText(False,0),doc.UserID(0)+";",doc.UserID(0)+";"+doc.YesorNo(0)))

End If

If InStr(rtfitem.GetFormattedText(False,0),doc.UserID(0)+";")<>0  Then

Call temprtf.Appendtext(Replace(rtfitem.GetFormattedText(False,0),doc.UserID(0)+";",doc.UserID(0)+";"+doc.YesorNo(0)))

End If

Call maindoc.Removeitem("ReadersID")

Set rtfitem=maindoc.Createrichtextitem("ReadersID")

Call rtfitem.Appendtext(temprtf.Text)

End If

Call maindoc.save(True,False)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值