Lotusscript:加载文档时无法获取Rich Text字段(保存前)

时间:2014-08-26 09:20:30

标签: lotus-notes attachment lotusscript richtext

我有一个关于lotusscript开发的问题。 嗯,这是我的情景:

  1. 我设计了一个名为“FORM”的表单
  2. 使用“FORM”
  3. 形式创建新文档
  4. 表单“FORM”包含名为“ListPod”的RichText字段
  5. 在编辑模式下打开文档时,我想直接在“ListProd”字段中自动附加文件(C:\ Files \ file.pdf)
  6. 我使用事件“OnLoad”来访问RichText字段并完成我的工作。

    我的问题是“ListProd”字段尚不存在。好吗?

    这是我的来源:

    Sub Onload(Source As Notesuidocument)
        Dim fileName As String 
        fileName$ = Dir$( "c:\Files\*.pdf", 0 )
        Print fileName$
        If Not ( fileName$ = "" ) Then
            Dim object As NotesEmbeddedObject
            Dim rtItem As NotesRichTextItem
            Set rtItem = Source.Document.GetFirstItem("ListProd")
            If rtItem.Type = RICHTEXT Then
                Set object = rtitem.EmbedObject(EMBED_ATTACHMENT, "", "c:\Files\"+fileName$)            
            End If
        End If
    End Sub
    

    “rtItem.Type”因“rtItem”为NULL而引发错误。我该怎么办才能访问这个领域?

    提前谢谢

2 个答案:

答案 0 :(得分:0)

使用QueryOpen事件并尝试使用NotesRichTextItem构造函数重新创建项目:

Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant, Continue As Variant)

    Dim doc As NotesDocument
    Dim rtitem As NotesRichTextItem
    Dim bIsNewDoc As Boolean

    Set doc = Source.Document

    bIsNewDoc = True

    If Not Isnewdoc And Not doc Is Nothing Then
        bIsNewDoc = doc.IsNewNote
    End If

    If Not bIsNewDoc And Mode% = 1 Then
        'Your code

        Call doc.RemoveItem("ListProd")
        Set rtitem = New NotesRichTextItem(doc, "ListProd")
        Call rtitem.EmbedObject(EMBED_ATTACHMENT, "", fileName$)

        'Your code
    End If

End Sub

答案 1 :(得分:0)

我在这里找到了一个解决方案

Validate rich text fields for attachments without saving the UI document

使用:uidoc.refresh是的,我可以将所有前端修改的信息传输到后端。因此,我可以访问我的' ListProd'没有保存的字段:)

霍普它可以帮助你:)