Solved

Formatting MS Word text after opening.

Posted on 2002-06-18
6
232 Views
Last Modified: 2012-08-13
Hi,
I have been given the task of loading a message into Word which is in gold font(I guess yellow would do). I can open Word no problem but I can't find any information about formatting the text to go inside. The script I am using is

<% @LANGUAGE = VBScript %>
<%
Response.ContentType = "application/msword"
Response.Expires = 0
%>
Message text would appear here (but where do I put the formatting?).

Thanks in advance

Sam
0
Comment
Question by:Sambob
6 Comments
 
LVL 20

Accepted Solution

by:
Silvers5 earned 100 total points
ID: 7090565
try pure html.. it should work..
<% @LANGUAGE = VBScript %>
<%
Response.ContentType = "application/msword"
'Response.Expires = 0  
%>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>
<body>
<p><font color="#FFCC00"><b>Hello world!</b></font></p>
</body>
</html>
0
 

Author Comment

by:Sambob
ID: 7090620
The books I have been looking at suggest that HTML tags would be displayed along with the text so I didn't even bother trying that approach. I'll have a look in the morning and award you the points if all is OK.
Thanks
Sam
0
 
LVL 1

Expert Comment

by:sandyphillips
ID: 7090622
Sambob,

If I understand what you are trying to do, the scripting host will continue to use the "context" you opened up with your command Response.ContentType. That is, it will essentially "open" MS Word in your browser window. Thus, to get a message in a particular color, you could use the Write method of the Response object. So, if I want to have a formatted message, I would use something like the following:

<%
Response.Write "<font color='blue'>This is the one!</font>"
%>

This puts your formatting in-line and lets Word receive the output of the Response object. This will allow you to use all the VBScripting power to format and use variables to create your message.

If you want just plain simple, just embed standard HTML after your ASP command close marker (the %> sign) and Word will interpret it directly. So, in this case, it would look like:

<% @LANGUAGE = VBScript %>
<%
Response.ContentType = "application/msword"
Response.Expires = 0
%>
<font color='blue'>This is the one!</font>.

To show you both, I have composed a little ASP that has both methods (although I don't use any real features of VBScript, it does illustrate the point):
<html>
<!-- Creation date: 6/18/2002 -->
<head>
<title>ASP and Word Demonstration</title>
<meta name="description" content="Demonstration of Word Control from ASP">
<meta name="author" content="sphillips77">
</head>
<body>
<% @LANGUAGE = VBScript %>
<%
Dim strMsg
     strMsg     =     "Message from VBScript!"
     
Response.ContentType = "application/msword"
Response.Expires = 0
Response.Write "<center><h1><font color='blue'>" + strMsg + "</font></h1></center>"
Response.Write "<br><hr><br>"
Response.Write "<p align='center'><font color='green'>Brought to you by MS Scripting Host</font></p>"
%>
<br><hr><br>
<center><h1><font color='blue'>Your plain HTML message here.</font></h1></center>
<p align='center'><font color='green'>Brought to you by MS Scripting Host</font></p>

</body>
</html>

I hope this helps.
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 29

Expert Comment

by:Göran Andersson
ID: 7091448
sandyphillips, welcome to EE.
:)

The practice here is not to propose an answer, unless you are:
- first to suggest an answer
- totally covering the subject, leaving nothing more to say

The reason for this is that when you propose an answer, the question is moved to the Locked Questions. That means that few experts will even look at it, so the person asking the questions will probably not getting any more input. That's not really fair to him.

Please read the tips on comments and answers below.
0
 

Author Comment

by:Sambob
ID: 7096117
sandyphillips,
sorry! the question had already been answered adequately by Silvers5 but thank you for answering anyway,
Sam
0
 

Author Comment

by:Sambob
ID: 7096122
How do I now award the points to Silvers5?
Sam
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
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…

809 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