This forum is closed to new posts and
responses. The content has been migrated to the Digital Solutions Community. Please join us there for new content as well as this content. For customer support, please visit the official HCL customer support channels below:
'Find the Attachments
Dim item As Variant
Set item = doc.GetFirstItem("Body")
Forall embobj In item.EmbeddedObjects
fname = embobj.name
End Forall
Set rtitem = doc.GetFirstItem( "Body" )
If ( rtitem.Type = RICHTEXT ) Then
'Check for attachment in Body item
Set object = rtitem.GetEmbeddedObject(fname)
If ( object Is Nothing ) Then
'Check for attachment in rest of document
Set object = doc.GetAttachment(fname)
End If
End If
TempPath$ = Environ("Temp")
fileatt = TempPath$ & "\" & fname ' Used to bedoc.subject(0) & Right$(fname, 4)
Call ShellExecute(0, "Open", fileatt, "", "", SW_SHOW)
End Sub
The user clicks the EDIT button, it sets the edit flag, sets the file location, and then uses the Shell command to launch the temp file.
The user edits the file in the appropriate application, and then comes back to Lotus Notes. Since the document has been edited, they are asked to save the Notes document when they close it. IF they say "Yes" or even if they save the document, the following code in the querysave of the form picks up the last extracted attachment and pulls it back into the document:
Sub Postsave(Source As Notesuidocument)
If Source.FieldGetText("tmpOpenForEdit")="1" Then
'Find the Attachments
Dim item As Variant
Dim ws As New NotesSession
Dim doc As NotesDocument
Set doc=source.document
'Find the Attachments
Set item = doc.GetFirstItem("Body")
Forall embobj In item.EmbeddedObjects
fname = embobj.name
End Forall
Set rtitem = doc.GetFirstItem( "Body" )
If ( rtitem.Type = RICHTEXT ) Then
'Check for attachment in Body item
Set object = rtitem.GetEmbeddedObject(fname)
If ( object Is Nothing ) Then
'Check for attachment in rest of document
Set object = doc.GetAttachment(fname)
End If
End If