?
Solved

Formatting MS Word text after opening.

Posted on 2002-06-18
6
Medium Priority
?
241 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
[X]
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
6 Comments
 
LVL 20

Accepted Solution

by:
Silvers5 earned 400 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

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…
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…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

777 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