Hi.I want my script to find specified attachment in a document and run this attachment to edit. Is there a way how to handle it?
Thanks in advance. Jiri.
Hi.I want my script to find specified attachment in a document and run this attachment to edit. Is there a way how to handle it?
Thanks in advance. Jiri.
Subject: How to edit attachment from Lotus script
Use the ‘NotesEmbeddedObject class’:
This is in the Help, and I suggest that you search this and previous forums for the answer if you need further help…!
Dim doc As NotesDocument
Dim rtitem As Variant
'************…set value of doc…
Set rtitem = doc.GetFirstItem( “Body” )
If ( rtitem.Type = RICHTEXT ) Then
Forall o In rtitem.EmbeddedObjects
If ( o.Type = EMBED_ATTACHMENT ) Then
Call o.ExtractFile( "c:\samples\" & o.Source )
Call o.Remove
Set handle = o.Activate( False )
If ( handle Is Nothing ) Then
doc.Subject = “This object has no OLE automation interface”
Else
doc.Subject = “This object has an OLE automation interface”
End If
Call doc.Save( False, True )
End If
End Forall
End If
HTH,
Ranjan
Subject: RE: How to edit attachment from Lotus script
Sorry, it doesn’t work.
Subject: RE: How to edit attachment from Lotus script
You need to make sure you set the value of ‘Doc’ as indicated in the comments of the code.
The idea of the code is to give u an idea - not to do the work for you!!
Bye,
R
Subject: RE: How to edit attachment from Lotus script
Hi Ranjan. Sorry to “complain”, but this code could never be used.
By definition, a NotesEmbeddedObject of type EMBED_ATTACHMENT may not be activated via the activate method. From Designer Help on the activate method “This method raises an error if you invoke it on a NotesEmbeddedObject that is a file attachment”
Furthermore, you activate the object after removing it from the document, rather than sing ShellExecute (or similar WinAPI) to activate the extracted file.
Subject: RE: How to edit attachment from Lotus script
Hi Morten,
Thanks for your feedback.
I was trying to give you guys an idea of where to look without actually writing the code…you can go round the houses and re-embed the attachment from the file system - as an embedded object, then invoke the activate method, or you could use the winapi call…you could even do it without deleting it from the document…but that’s all up to you!
I was merely trying to show how much info is available in the help - which I think is a better place to start b4 posting here…also I’m sure I’ve seen the answer to that question in the earlier R5 forum…
I hope that’s been helpful…
Cheers,
R
Subject: RE: How to edit attachment from Lotus script
Hi Ranjan,
vour code is interesting but you need to extract the attachment to the disk and after that you remove the attachment, but do you know if it’s possible to edit the attachment directly from the notes document (without extract) so that the user can work with it and save it into the notes document ?
TIA
Jean-Michel
Subject: RE: How to edit attachment from Lotus script
Once again - the code is there to give you an idea. You can remove the part which detaches and deletes the attachment (that was there to give you an idea on how to manipulate the attachment further and an idea of the richtext class, etc.). If you need any further help - let me know.
Cheers,
R
Subject: The answer…
A workaround to edit the attachment can be:
Declarations:
Declare Sub keybd_event Lib “user32.dll” (Byval bVk As Integer, Byval bScan As Integer, Byval dwFlags As Integer,Byval dwExtraInfo As Integer)
Initialize:
keybd_event 18,0,0,0 ’ Alt key down
keybd_event Asc(“T”),0,0,0 ’ T key down
keybd_event Asc(“T”),0,2,0 ’ T key up
keybd_event 18,0,2,0 ’ Alt key up
keybd_event Asc(“E”),0,0,0 ’ E key down
keybd_event Asc(“E”),0,2,0 ’ E key up
No functions are available in ls or formula to simulate right click and edit