Skip to main content
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:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal

HCL Notes/Domino 8.5 Forum (includes Notes Traveler)

HCL Notes/Domino 8.5 Forum (includes Notes Traveler)

Previous Next

Here's how you do it...

G'Day Terry, you can do this pretty easily.

You need two hidden fields, these contain the flags to determine

a) whether the document has been edited, and
b) the file path for the extracted attachment

Then create a button on the Form, let's call this "EDIT":

Sub Click(Source As Button)

Dim s As New NotesSession
Dim ws As New NotesUIWorkspace
Dim doc As NotesDocument
Dim uidoc As NotesUIDocument

Set uidoc = ws.currentdocument
Set doc = uidoc.document

uidoc.EditMode=True
Call uidoc.FieldSetText("tmpOpenForEdit","1")


'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 uidoc.FieldSetText("tmpFileLocation", fileatt)

Call object.ExtractFile(fileatt)

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



fileatt = source.FieldGetText("tmpFileLocation")

Call object.Remove
Call rtitem.Update
Call doc.Save(True, True)

Set object = rtitem.EmbedObject( EMBED_ATTACHMENT, "", fileatt)
Call rtitem.Update

Kill fileatt

Call source.FieldSetText("tmpOpenForEdit","0")
Call source.FieldSetText("tmpFileLocation","")

Call doc.Save(True, True)
End If


End Sub

Hope this helps.

Kind regards,

Mat


Feedback response number WEBB8R2TKF created by ~Patti Brelukonyobu on 01/31/2012

Is there any way to launch a (hidde... (~Wei Asatoopula... 25.Jan.12)
. . Event on Form (~Hal Fronilitob... 27.Jan.12)
. . . . Yes, I am familiar with form events... (~Wei Asatoopula... 29.Jan.12)
. . Here's how you do it... (~Patti Brelukon... 31.Jan.12)
. . . . Cheers Mat! (~Wei Asatoopula... 1.Feb.12)
. . The 'native ability' of Notes to ed... (~Fred Asatumibu... 29.Jan.12)




Printer-friendly

Search this forum

Member Tools


RSS Feeds

 RSS feedsRSS
All forum posts RSS
All main topics RSS