我有一个要求,其中有一个带有附件的文档,当我点击一个按钮时,它会打开一个新表单。此表单必须在富文本字段中包含该附件。我在打开的新表单的 PostOpen 事件中编写了以下代码
Set item1= tardoc.GetFirstItem("Comments")
Set item= sourcedoc.GetFirstItem("Current_US")
If Not item Is Nothing Then
If item.Type = RICHTEXT Then
Set rtitem = item
If Not Isempty(rtitem.EmbeddedObjects) Then
Forall fileItem In rtitem.EmbeddedObjects
If fileItem.Type = EMBED_ATTACHMENT Then
Call fileItem.ExtractFile(filepath _
& Cstr(fileItem.Name))
attFile = filepath & Cstr(fileItem.Name)
Call item1.EmbedObject( EMBED_ATTACHMENT, "", attFile)
End If
End Forall
End If
End If
End If
sourcedoc 是必须从中复制附件的文档,tardoc 是必须将附件复制到的文档,它也是打开的新文档,所以在这个表单的 postopen 事件中我已经写好了代码。但是在这一行代码失败说对象变量未设置。 调用 item1.EmbedObject( EMBED_ATTACHMENT, "", attFile)
最佳答案
该代码在 Postopen 事件中不起作用,因为更改富文本字段为时已晚。
在带有后端类的按钮中创建文档,然后打开文档进行编辑。
Dim session As New NotesSession
Dim workspace As New NotesUIWorkspace
Dim tardoc As NotesDocument
Dim item1 As NotesRichTextItem
Set tardoc = session.CurrentDatabase.CreateDocument
tardoc.Form = "YourForm"
Set item1= tardoc.CreateRichtextItem("Comments")
Set item= sourcedoc.GetFirstItem("Current_US")
If Not item Is Nothing Then
If item.Type = RICHTEXT Then
... your code ...
End If
End If
Call workspace.EditDocument(True, tardoc)
由于 tardoc 是一个新文档,您必须先创建目标富文本字段
Set item1= tardoc.CreateRichTextItem("Comments")
关于lotus-notes - 将附件从一个表单复制到另一个 lotus notes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40904413/