I have opened Excel 2003 file just fine with "a little from my friends" here in this forum. Now I am trying to open an Excel 2007 file and I am using the following code.
I am getting the following error when I try this ...Code:Private Function OpenExcelTemplate(ByVal sTemplatePath As String) As Boolean Try Dim iPos As Integer = InStrRev(sTemplatePath, ".") If Len(sTemplatePath) - iPos = 3 Then Response.Clear() Response.AddHeader("content-disposition", "attachment;filename=FileName.xls") Response.Charset = "" Response.ContentType = "application/vnd.xls" Response.WriteFile(sTemplatePath) Response.Flush() Else Response.Clear() Response.AddHeader("content-disposition", "attachment;filename=FileName.xlsx") Response.Charset = "" Response.ContentType = "application/vnd.ms-excel" Response.WriteFile(sTemplatePath) Response.Flush() End If OpenExcelTemplate = True Catch ex As Exception Me.WucViewQuery1.DisplayError(ex.Message) End Try End Function
"Excel found unreadable content in 'FileName[1].xlsx'. Do you want to recover the contents of this workbook? If you trust the sourc of this workbook, click Yes."
When i click yes it tells me it can not open the file.
This file contains a pivot table but so does the Excel 2003 file.
I may be way off base with the determine which type of file and changing the AddHeader to match the file type, but I could not get the original method for opening an Excel 2003 file to work on the Excel 2007 file.![]()





Reply With Quote