判断RTF域是否有值(文本或附件):
On Error Goto label1
Dim ws As New notesuiworkspace
Dim uidoc As notesuidocument
Set uidoc=ws.currentdocument
Call uidoc.gotofield("richTextField") ‘将光标放在指定的域
Call uidoc.selectall ’在编辑状态下选择指定域中的内容,在阅读状态下,选择文件的所有内容
Call uidoc.deselectall ‘取消选择,如果没有选择任何,会报错“Document command is not available”
Exit Sub
label1:
Messagebox("RTF IS NULL!")
Exit Sub
判断RTF域是否有附件:
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Set uidoc = ws.CurrentDocument
Set doc = uidoc.Document
Dim rtitem As Variant
Call uidoc.Save
Set rtitem = doc.GetFirstItem("richTextField")
On Error Goto label1
If rtitem.Type = RICHTEXT Then
Forall o In rtitem.EmbeddedObjects '如果没有附件,这句会报错
If o.Type = EMBED_ATTACHMENT Then
Messagebox("RTF field contains attachment")
Exit Sub
End If
End Forall
End If
label1:
Messagebox("RTF field not contains attachment")
Exit Sub
下载附件到本地磁盘:
Call o.ExtractFile("D:\" & o.Source)