I have strange problem, my code creates a file (named as .xls & not using excel objects) and attaches it to a document. When I open this document in my browser (IE) I can see the attachment but it doesn’t open when trying to do so.
I have tried opening from Notes Client, it works fine. I noticed the properties show file size as “ 0 bytes (?) “. There is no error reported in the log file.
Any suggestions to make this work ie to open the attachment in the document through browser
Here is my code
Sub ExcelExport
On Error Goto ErrorHandle
Dim destDoc As NotesDocument
Dim rtitem As NotesRichTextItem
Dim object As NotesEmbeddedObject
Dim coll As Long
fileHandle("ExcelExport") = Freefile()
coll = vw.FTSearch( strSearch, 0 )
‘ Setting the directory path
sysPath = session.GetEnvironmentString("Directory", True)
Open sysPath & "\domino\html\" & fileName For Output As fileHandle("ExcelExport")
Dim strRecHeader As String
Forall c In vw.Columns
strRecHeader = strRecHeader & c.Title & strDelimiter
End Forall
Print # fileHandle("ExcelExport"), strRecHeader
Set doc = vw.GetFirstDocument
While Not (doc Is Nothing)
counter = counter +1
Dim strRecord As String
strRecord = ""
For j = 0 To vw.ColumnCount-1
strRecord = strRecord & doc.ColumnValues(j) & strDelimiter
Next
Print #fileHandle("ExcelExport"), strRecord
Set doc = vw.GetNextDocument(doc)
Wend
' Create Document and to the file generated & delete it from the local file system.
Set destDoc = db.CreateDocument
destDoc.Form = "DownloadFiles"
Call destDoc.Save( True, True )
Set rtitem = New NotesRichTextItem( destDoc, "fileName" )
Set object = rtitem.EmbedObject(EMBED_ATTACHMENT, "", sysPath & "\domino\html\" & fileName)
Call destDoc.Save( True, True )
Close fileHandle("Export")
Kill sysPath & "\domino\html\" & fileName
destDocURL = "http://"& curDoc.srvName(0) & "/" & curDoc.Path(0) & "/Dall/" & destDoc.UniversalID & "?OpenDocument"
'Prepare HTML Page for user to view results & save the file
Call vw.Clear
Exit Sub
ErrorHandle:
Print "Error in data export " & Error & " Please contact admin with the error details"
Err = 0
Resume Next
End Sub