Hi,I have attachments contained in a rich text item.
Set oEmbedded = ortitem.EmbedObject ( EMBED_ATTACHMENT, “”, filename )
and users can see the attachments stored in document, with an action:
Set ortitem = odoc.GetFirstItem( “rtxt” )
If ( ortitem.Type = RICHTEXT ) Then
Forall o In ortitem.EmbeddedObjects
If ( o.Type = EMBED_ATTACHMENT ) Then
Call o.ExtractFile("c:\" & o.Source )
End If
End Forall
End If
My problem is when users try to save the document with the notes toolbar save action, and without closing the document they try save document again with my action “Save&Close”.
Save & close code:
Set uidoc = Espacio.CurrentDocument
Set odoc = uidoc.document
If odoc.HasEmbedded Then
odoc.SaveOptions = “0”
End If
Call odoc.Save(True,True)
Call uidoc.Refresh
If Not (odoc.HasEmbedded) Then uidoc.Save
Call uidoc.Close(True)
QuerySave:
If source.document.name(0)<>”” Then Call Source.Refresh Else Continue=False
If source.document.HasEmbedded Then
source.document.SaveOptions = “0”
End If
Call source.document.Save(True,True)
Call source.Refresh
I think what’s happening is that the user is attaching the file to the RTF in the frontend UI document, and it creates the $FILE item to store the attachment, but there isn’t the file itself in the RTF.
I think, I’m saving the backend document before the UI document is saved and changes to the UI document are not reflected in the backend document.
When I open the document again,there is an attachment in the document that’s not linked to in a RTF, and when users try to see the selected attachment, in the first line :
Forall o In ortitem.EmbeddedObjects
they get the error: “type mismatch”, because ortitem.EmbeddedObjects is empty
Any ideas, to resolve this problem?
Thanks in advance,