Solved

Formatting MS Word text after opening.

Posted on 2002-06-18
6
226 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 29

Expert Comment

by:Göran Andersson
Comment Utility
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
Comment Utility
sandyphillips,
sorry! the question had already been answered adequately by Silvers5 but thank you for answering anyway,
Sam
0
 

Author Comment

by:Sambob
Comment Utility
How do I now award the points to Silvers5?
Sam
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Webdav server error 405 using iannotate on ipad 11 135
Current Date/Time SQL Azure 12 94
syntax error on ASP ? 6 39
API not working 33 47
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now