Hi,
Can anyone help me with finding a solution to editing an attachment directly from a Notes form. I’ve read through some old posts and it seems as through I need to detach the file, open the file, make changes and then save the document back to the form. I’m fine with detaching the file and opening it, but am stuck in how I then attach the file back AFTER the user has made changes. I also tried using the .activate method, but it seems this can only be used for embedded objects, not attachments. My sample code is shown below:
Function EditBriefDocument(COAGDocument As NotesDocument) As NotesDocument
'CreatebriefDocument
'Parameters
'COAG Document : The Document that the brief is being created for.
'Description
'This function will create/edit a brief document for the specified COAG document.
Dim BriefTemplate As Variant
Dim OutputPath As String
Dim LeadBranch As String
Dim Branchheads As Variant
Dim PolicyOfficerNo As String
Dim BranchManagerNo As String
Dim Session As New NotesSession
Dim BriefDocument As NotesDocument
Dim BriefEmbeddedField As NotesRichTextItem
Dim WorkSpace As New NotesUiWorkSpace
Dim AuthorsList As NotesItem
Dim ReadersList As NotesItem
If BriefExists(COAGDocument, BriefDocument) Then
If Not BriefDocument Is Nothing Then
Set EditBriefDocument = BriefDocument
’ Exit Function
End If
End If
Dim myApp As Variant
Set myApp = CreateObject("Word.Application")
'Hiding word from the user
myApp.Visible = True
Dim ExtractDir As String
ExtractDir = Environ$("TEMP")
If ExtractDir = "" Then ExtractDir = Environ$("TMP")
If ExtractDir = "" Then
Msgbox "No temporary directory is specified with the TEMP or TMP environment variables", 16, "Error"
’ GetTempDirs = “”
End If
' terminate with \
If Right$(ExtractDir, 1) <> "\" Then
ExtractDir = ExtractDir & "\"
End If
Dim rtitem As Variant
Dim sfile As String
Set rtitem = editbriefdocument.GetFirstItem("BriefDocument")
Forall o In rtitem.EmbeddedObjects
If ( o.Type = EMBED_ATTACHMENT ) Then
sfile = o.source
Call o.ExtractFile( ExtractDir & sfile )
Call o.remove
End If
End Forall
OutputPath = ExtractDir & sfile
myApp.Documents.Open OutputPath
Set BriefEmbeddedField = New NotesRichtextItem(BriefDocument,"BriefDocument")
Call BriefEmbeddedField.EmbedObject (EMBED_ATTACHMENT, "", OutputPath)
Call BriefDocument.Save(False,False)
End Function