Hi there
When I run a report through asp I actually export to a PDF File, but I have allowed for other file types (such as word to be used. I set up my report with an openreport function then I called a Function called DisplayReport which looks like this:
I hope this helps!!!
Function DisplayReport(oRpt,FileType,blnForDownload)
Dim strDocumentName, strExt, strPath,iLen
'Set Format type and ext.
With oRpt.ExportOptions
Select Case FileType
Case crMSWord
.FormatType = 14
strExt = ".doc"
Response.ContentType = "application/msword"
Case crMSExcel
.FormatType = 21
strExt = ".xls"
Response.ContentType = "application/vnd.ms-excel"
Case crMSExcelTab
.FormatType = 22
strExt = ".xls"
Response.ContentType = "application/vnd.ms-excel"
Case crHTML
.FormatType = 24
strExt = ".html"
Response.ContentType = "text/html"
Case crPText
.FormatType = 10
strExt = ".doc"
Response.ContentType = "application/msword"
Case crRTF
.FormatType = 4
strExt = ".rtf"
If blnForDownload Then
Response.ContentType = "text/richtext"
Else
Response.ContentType = "application/msword"
End If
Case crTXT
.FormatType = 8
strExt = ".txt"
If blnForDownload Then
Response.ContentType = "text/plain"
Else
Response.ContentType = "text/html"
End If
Case crTAB
.FormatType = 6
strExt = ".csv"
If blnForDownload Then
Response.ContentType = "text/plain"
Else
Response.ContentType = "application/vnd.ms-excel"
End If
Case crCSV
.FormatType = 5
strExt = ".csv"
If blnForDownload Then
Response.ContentType = "text/plain"
Else
Response.ContentType = "application/vnd.ms-excel"
End If
Case crPDF
.FormatType = 31
strExt = ".pdf"
Response.ContentType = "application/pdf"
Case Else
.FormatType = 31
strExt = ".pdf"
Response.ContentType = "application/pdf"
End Select
strPath = Request.ServerVariables("PATH_TRANSLATED"
While (Right(strPath, 1) <> "\" And Len(strPath) <> 0)
iLen = Len(strPath) - 1
strPath = Left(strPath, iLen)
Wend
strDocumentName = Year(Date) & Month(Date) & Day(Date) & Hour(Time) & Minute(Time) & Second(Time) & strExt
strPath = strPath & strDocumentName
.DestinationType = 1
.DiskFileName = strPath
End With
oRpt.Export False
Set oRpt = Nothing
' download file
Dim str
set str = createobject("ADODB.Stream"

str.type = 1
str.open
str.LoadFromFile strPath
If blnForDownload Then
Response.Addheader "Content-Disposition", "attachment;filename=" & strDocumentName
End IF
Response.BinaryWrite str.Read
set str = nothing
Dim FSO
Set FSO = Server.CreateObject("Scripting.FileSystemObject"
If FSO.FileExists(strPath) Then
FSO.DeleteFile(strPath)
End If
Set FSO = Nothing
End Function
Transcend