我有一个关于lotusscript开发的问题。 嗯,这是我的情景:
我使用事件“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而引发错误。我该怎么办才能访问这个领域?
提前谢谢
答案 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'没有保存的字段:)
霍普它可以帮助你:)