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

Posted on 2004-10-01
Last Modified: 2008-02-20

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/"
Question by:TrueBlue
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 15

Expert Comment

ID: 12205906
    Response.AddHeader "Content-Disposition", "attachment; filename=statement.xls"

Author Comment

ID: 12205956
Hi Thogek!

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

Any other ideas?
LVL 15

Expert Comment

ID: 12206040
What do you mean by "it shows part of the page's URL"?  Where?
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 15

Accepted Solution

Thogek earned 250 total points
ID: 12206043
And make sure that these statements are being called before any Response.Write calls.

Author Comment

ID: 12206046
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

Author Comment

ID: 12206072
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.

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: and…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question