When calling Excel the assigned file name is substituted with part of the URL

Hi!

I have the following VBScript code:

For some reason when the page is called instead of passing the below listed filename it shows part of the page's URL which will not work with Excel.

Any ideas?

     ' set the filename to statement.xls
      Response.AddHeader "Content-Disposition", "filename=statement.xls"
     ' set the mime type to Microsoft Excel
      Response.ContentType = "application/vnd.ms-excel"
TrueBlueAsked:
Who is Participating?
 
ThogekConnect With a Mentor Commented:
And make sure that these statements are being called before any Response.Write calls.
0
 
ThogekCommented:
Try
    Response.AddHeader "Content-Disposition", "attachment; filename=statement.xls"
0
 
TrueBlueAuthor Commented:
Hi Thogek!

I tried your suggestion, but I am still getting the same problem.

Any other ideas?
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
ThogekCommented:
What do you mean by "it shows part of the page's URL"?  Where?
0
 
TrueBlueAuthor Commented:
Hi Thogek!

When the window pops up. It says "Do you want to open or save this file?"
Name: ExcelAROpenTrans_ASP?ID=1234
Type: Microsoft Excel Worksheet, 2.57KB
From: secured.domain.com
0
 
TrueBlueAuthor Commented:
Hi Thogek!

I figured it out. There was a type mismatch that was causing the wrong filename to be displayed.

I commented out the lines so that the data would be displayed on the screen as opposed to being sent to Excel and discovered the mismatch error.

Thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.