Hi all,
I have a requirement to download the attachments in a (richtext field) document to a local drive. I have an agent for this and all are going well.
A user has inserted a Paperport document by clicking a button and I am not able download the attachment to the Local drive.
Code for inserting paperport scanned document is as follows
@PostedCommand([EditInsertObject]; “PaperPort Document”)
Below is the agent I am using for downloading the attachment to the Local drive. I encounter error at in the command "Call handle.saveas(destnPath(0) + “" + filename)”.
Sub Initialize()
Dim session As New NotesSession()
Dim db As NotesDatabase
Dim vwDetail As NotesView
Dim entries As NotesViewEntryCollection
Dim currEntry As NotesViewEntry
Dim doc As NotesDocument
Dim rtitem As Variant
Dim ObjWd As Variant
Dim PP_obj As variant
'Set PP_obj = CreateObject("PaperPortApplication")
Set db = session.Currentdatabase
Set vwDetail = db.Getview("Attachment View")
If (vwdetail Is Nothing) Then
MsgBox "View not found"
Exit Sub
End If
Dim ws As New NotesUIWorkspace
Dim destnPath As Variant
destnPath = ws.Savefiledialog(True, "Select a Folder to Save Attachments")
If IsEmpty(destnPath) Then
Exit Sub
End If
Set entries = vwdetail.Allentries
Set currEntry = entries.Getfirstentry()
Dim iCnt As Integer
iCnt = 0
Dim handle As Variant
While( Not (currEntry Is Nothing))
'Checks whether document has Attachments.
If currEntry.Document.Hasembedded Then
Set doc = currEntry.Document
Set rtitem = doc.GetFirstItem( "FileAttach" )
If ( rtitem.Type = RICHTEXT ) Then
ForAll o In rtitem.EmbeddedObjects
If o.Type = EMBED_ATTACHMENT Or o.Type = EMBED_OBJECT Or _
o.Type = EMBED_OBJECTLINK Then
Set handle = nothing
Dim fileName As String
fileName = o.Source
Dim object As NotesEmbeddedObject
set object = currEntry.Document.Getattachment(o.Source)
'If it is an embeded object and Activate it and Save
If o.Type = EMBED_OBJECT Then
Set handle= object.Activate(False)
Call handle.saveas(destnPath(0) + "" + filename)
Else
object.Extractfile(destnPath(0) + "\" + fileName )
End If
iCnt = iCnt + 1
fileName = ""
End If
End ForAll
End If
End If
Set currEntry = entries.Getnextentry(currEntry)
Wend
MessageBox "Extracted " + CStr(icnt) + " files to the Folder: """ + _
+ CStr(destnPath(0)) +""" successfully.", _
0 + 64,"Extract Attachments"
End Sub
How can I download the paperport documents without error? Please help me. Your help will be highly appreciated.