CJM wrote:
> [Apologies for previous half-post: I regularly mistype some kind of key
> combo that submits the post]
>
> I have a page on our intranet that is supposed to stream an Excel sheet to
> the user. I'm using pretty standard code:
>
> sFilePath = sFileDir & sFilename
>
> Response.AddHeader "content-disposition","attachment; filename=" & sFilePath
>
> ' Create your header information
> Response.ContentType = "application/x-msexcel"
>
> ' Create and configure your object
> Set oFStream = Server.CreateObject("ADODB.Stream")
> oFStream.Open
> oFStream.Type = 1
> oFStream.LoadFromFile(sFilePath)
>
> ' Stream it to the client
> Response.BinaryWrite oFStream.Read
>
> ' Cleanup
> oFStream.Close
> Set oFStream = Nothing
>
> ' force the end
> Response.End
>
> This works fine on the main server, but not on my development machine (XP
> Pro x64). This has all worded in the past, but this is a new machine, and I
> can't get it to work since I've moved across. I'm getting a 'File could not
> be opened' error message. In the past, I've had this error when I wasn't
> pointing at the right place or where the permissions were not configured
> correctly.
Comment out the response.contenttype and the response.addheader lines,
and you will see your ASP error.
If your ASP is generating errors, it's that message that Excel is
trying to open as an excel file, hence the "file could not be opened"
message.
|