Hi,
I am trying to add a doclink where the attachment/file was in the middle of the text. I cannot see it in the debugger but I assumed that rtnav would have the position of the attachment, it still adds the doclink at the end of the richtext.
From this function I tried to get the location of the attachment detach it and then add the doclink
Dim rtitem As NotesRichTextItem
Dim InfoFileNameAs Variant
Dim rtnav As NotesRichTextNavigator
Dim obj As NotesEmbeddedObject
Set rtitem = doc.GetFirstItem( Item.Name )
If ( rtitem.Type = RICHTEXT ) Then
If Not IsEmpty (rtitem.EmbeddedObjects) Then
ForAll o In rtitem.EmbeddedObjects
Stop
Set rtnav = rtitem.CreateNavigator
Set obj = rtnav.GetFirstElement(RTELEM_TYPE_FILEATTACHMENT)
While Not (obj Is Nothing)
' here is where we detach the file
Call AttachementDetacher(obj, InfoFileName)
Dim docAttachment As New NotesDocument(dbAttachmentOpen)
Dim rtitemATT As New NotesRichTextItem(docAttachment, "Body")
' WE create the new doc in the Attachments file database
Call GetOutFileAttachment(obj, InfoFileName, rtitemATT, doc, docAttachment, Item.Name, rtnav)
' the function GetOutFileAttachment below I want to add the link and via the rtnav (I suppose that it ' contains the position where the attachment was)
'
Call rtitem.AddNewLine( 1 )
Call rtitem.AppendDocLink( docAttachment, InfoFileName)
Call doc.Save( True, True )
Set obj = rtnav.GetNextElement(RTELEM_TYPE_FILEATTACHMENT)
Wend
End ForAll
End If
End If
End Function
Function GetOutFileAttachment(o, InfoFileName, rtitemATT, doc, docAttachment, Item, rtnav)
Dim itemName As NotesItem
If docAttachment Is Nothing Then
Call rtitemATT.BeginInsert(rtnav)' ********* I cannot see it in the debugger but I assumed that rtnav had the position of the attachment, it still addes the doclink at the end of the richtext.
Call rtitemATT.embedobject(Embed_Attachment, "", "C:\temp\" + o.name )
Call doc.Save( True, True )
Else
docAttachment.Form = "Attachments"
If doc.form(0) = "frmDSER" Then
docAttachment.Dem_No = doc.Dem_No(0)
docAttachment.Date_Creation = CStr(doc.Date_Creation(0))
docAttachment.InfoFileName = InfoFileName
Else
docAttachement.Dos_No = doc.No_Dos_Reponse(0)
docAttachement.Date_Creation = CStr(doc.Date_Creation(0))
docAttachement.InfoFileName = InfoFileName
End If
docAttachement.NoID = doc.REF(0)
docAttachement.AttachProvChamp = Item
docAttachement.AttachProvDoc = doc.form(0)
Call rtitemATT.embedobject(Embed_Attachment, "", "C:\temp\" + o.name )
Call docAttachment.Save( True, True )
End If
Kill "C:\temp\" + o.name
Call o.remove
End Function