An user came up to me with a problem of adding an attachment to a form by using a button on the form (this db is a notes based db). When pressing the button, a pop-up window displays asking for what type of file the user is opening and the file itself. The problem is that when the user selects a file that is in 5 folders (Ex: D:\My Documents\Customer Opportunities\Customer Files\ASC Fed Opps\ASC FALCON\ASC Falcon Discovery kits COST and Services Summary 10-24-06.xls), she will receive the error “File not found”.
I tried to solve this problem in several ways:
-
I asked her to reduce the name of the file and she continued to receive the error.
-
I asked her to take out the file of all folders and put it on her desktop and try to add the attachment. She did not receive the error and was able to add the attachment.
-
She tried a different file that was in the same folders as the example and did not receive any errors.
The code for the “Add Attachment” button is below. Any help would be appreciated.
Dim ws As New NotesUIWorkspace
Dim ns As New NotesSession
Dim SourceDoc As NotesUIDocument
Dim db As NotesDatabase
Dim thisDoc As NotesDocument
Dim attdoc As NotesDocument
Dim flag As Integer,pos As Integer
Dim rtItem As NotesRichTextItem
Dim multfiles As Variant,temp As String ',filename As String
Dim secureArray(1) As String
Dim view As NotesView
Set SourceDoc=ws.CurrentDocument
secureArray(0)=“NotesAdmin”
secureArray(1)=“[SOW]”
flag = ws.DialogBox( “attachmentPopup” , True, True , True, True, False, False, “Add Attachment”, False, True )
If flag Then
Set db=ns.CurrentDatabase
Call SourceDoc.FieldSetText (“AttFileName”,ns.GetEnvironmentString(“AttFileName”))
Call SourceDoc.Refresh
Set thisDoc=SourceDoc.document
multFiles=thisDoc.AttFileName
Forall filename In multFiles
Set attdoc=db.CreateDocument
attdoc.Form="Attachment"
pos=0
For i=Len( filename) To 1 Step -1
temp=Mid(filename,i,1)
If temp="\" Then
pos=i
Exit For
End If
Next
pos=Len(filename)-pos
attdoc.attname=Right$( filename,pos)
attdoc.Description= SourceDoc.FieldGetText(“Description”)
attdoc.AttType= SourceDoc.FieldGetText(“AttType”)
attdoc.ATTACH_CREATED = Today
If isSecured(attdoc.AttType(0)) Then
attdoc.readers=secureArray
attdoc.GetFirstItem("readers").IsReaders=True
End If
Set rtItem=attdoc.CreateRichTextItem(“attachment”)
Call rtItem.EmbedObject ( EMBED_ATTACHMENT, “”,filename)
Call attdoc.MakeResponse(thisDoc)
Call attdoc.Save(True,True)
End Forall
Call SourceDoc.FieldSetText(“AttFileName”,“”)
Call SourceDoc.FieldSetText(“Description”,“”)
Call SourceDoc.FieldSetText(“AttType”,“”)
Call SourceDoc.Refresh
Set view=db.GetView(“attachments”)
Call view.refresh
Call ws.viewRefresh
End If