Subject: RE: Editing attachment directly-postopen event
fine… here is the code.If you are opening the UIDOC in edit mode, you’ll need to create a hidden text editable field called SaveOptions. It doesn’t need any default value not anything in it…it just must be there so we can close the uidoc without asking the user if they want to save their changes (which there won’t be any need to ask).
Paste this entire snippet into Declarations and it will move itself into the proper locations automatically.
Sub launchFile(FilePath As String)
Print “Launching attachment…”
Dim newTaskID As Integer
newTaskID% = Shell("rundll32.exe shell32.dll, OpenAs_RunDLL " & FilePath, 0)
End Sub
Sub Postopen(Source As Notesuidocument)
Dim s As New NotesSession
Dim db As NotesDatabase
Set db = s.currentdatabase
Dim uidoc As NotesUIDocument
Dim w As New NotesUIWorkspace
Set uidoc = w.currentdocument
Dim backendDoc As NotesDocument
Set doc = uidoc.Document
Dim object As NotesEmbeddedObject
If Not ( doc Is Nothing ) Then 'prevents code running on new doc
filenames=Evaluate(“@AttachmentNames”,doc)
numberoffiles=Evaluate(“@Attachments”, doc)
If numberoffiles(0)> 0 Then
For filecounter=0 To numberoffiles(0)-1
Print filenames(filecounter)
Set object = doc.GetAttachment( filenames(filecounter) )
If ( object.Type = EMBED_ATTACHMENT ) Then
fileCount = fileCount + 1
Call object.ExtractFile(Left((Trim(s.getEnvironmentString(“Directory”, True))),3) & filenames(filecounter) ) ’
Call launchFile(filenames(filecounter))
End If
Next filecounter
Msgbox "Total Files Detatched: " & Cstr(fileCount)
Call uidoc.FieldSetText(“SaveOptions”,“0”)
Call uidoc.Close(True)
End If
End If
End Sub
Let me know if you have any questions or problems.

(just made small edit to fix typo)