Solved

How to print <% Response.ContentType .... in a file ????

Posted on 2002-04-15
5
278 Views
Last Modified: 2012-08-13
<%
Set objFS =Server.CreateObject("Scripting.FileSystemObject")
Set objFN = objFS.CreateTextFile("c:\test.txt", true)
objFN.WriteLine("<% Response.ContentType = ""application/vnd.ms-excel"" %>")
Set objFN = Nothing
Set objFS = Nothing
%>


When I ran it, I got this error :

Unterminated string constant

/e.asp, line 4

objFN.WriteLine("<% Response.ContentType = ""application/vnd.ms-excel""
-----------------------------------------------------------------------^


How to fix it ? I must print <% Response.ContentType = "application/vnd.ms-excel" %> into a file.
0
Comment
Question by:decae2001
  • 3
5 Comments
 
LVL 20

Expert Comment

by:Silvers5
ID: 6943981
try

objFN.WriteLine(chr(60) & chr(34) & " Response.ContentType = "application/vnd.ms-excel" & chr(34) & chr(37) & chr(62))
0
 
LVL 20

Expert Comment

by:Silvers5
ID: 6943985
fix:

objFN.WriteLine(chr(60) & chr(34) & " Response.ContentType = " & chr(34) & "application/vnd.ms-excel" & chr(34) & 
chr(37) & chr(62))
0
 
LVL 20

Accepted Solution

by:
Silvers5 earned 200 total points
ID: 6943993
fixed final:

<%@ Language=VBScript %>
<%
Set objFS =Server.CreateObject("Scripting.FileSystemObject")
Set objFN = objFS.CreateTextFile(server.MapPath("test.txt"), true)
objFN.WriteLine(chr(60) & chr(37) & " Response.ContentType = " & chr(34) & "application/vnd.ms-excel" & chr(34) & chr(37) & chr(62))
Set objFN = Nothing
Set objFS = Nothing
%>
0
 
LVL 1

Expert Comment

by:falconew
ID: 6944308
Try this:
objFN.WriteLine("<% Response.ContentType = """application/vnd.ms-excel""" %>")

REgards,
Falconew
0
 
LVL 11

Expert Comment

by:ASPGuru
ID: 6944498
you don't really need to use the chr function... just make sure you separate the < and the % ....

objFN.WriteLine("<" & "% Response.ContentType .....


ASPGuru
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

832 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