473,386 Members | 1,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

ASP to Microsoft Word Automation

HI All

I just wonder if anyone has created a word document using ASP.

I am able to create a work document with ASP without any problem but what I
want to do is slightly more than I know. I am sure someone where will know
how to do the following.

We have a Word Template which is our standard contract type. I have some
data stored my access database record. I want to merge the two together.
i.e. take the data from access and insert into various points in the word
document. The points where I need to insert the data is definded by
Bookmarks in Word. This is how you can do it VBA but not sure if this is
possible in ASP.

In VBA I will write a statement like

With objWord
.Visible = True
.Documents.Add (WordTemplate)
.ActiveDocument.Bookmarks("GameDate").Select
.Selection.Text = (CStr(gamedate))
End With

Does anyone know the answer to the above issue or can you suggest an
alternative

thanks
Jul 22 '05 #1
2 3813
JP SIngh wrote:
HI All

I just wonder if anyone has created a word document using ASP.

I am able to create a work document with ASP without any problem but
what I want to do is slightly more than I know. I am sure someone
where will know how to do the following.

We have a Word Template which is our standard contract type. I have
some data stored my access database record. I want to merge the two
together. i.e. take the data from access and insert into various
points in the word document. The points where I need to insert the
data is definded by Bookmarks in Word. This is how you can do it VBA
but not sure if this is possible in ASP.

In VBA I will write a statement like

With objWord
.Visible = True
.Documents.Add (WordTemplate)
.ActiveDocument.Bookmarks("GameDate").Select
.Selection.Text = (CStr(gamedate))
End With

Does anyone know the answer to the above issue or can you suggest an
alternative

If it was a desktop app, I would not hesitate to suggest using Word
Automation for this. But seeing that you want to do it in a server app, I'm
much more hesitant. See:
http://support.microsoft.com/default...;en-us;q257757

I would rather create an html version of the Word template and use simple
string Replace to insert the data. You can use contentType to control what's
sent to the client.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 22 '05 #2
As per Bobs suggestion, use contentType as per this
technique:

http://www.devx.com/asp/Article/17964

First, get the data you need from Access and put each item
into a Session variable or an Array and store the array in
a session variable.

Then create your document as you want it to look in Word
with all its formatting ect. However whereever you want
to insert data from your Access database type something
like this (for full name):

VAR_PERSON_FULL_NAME

Then save your template as an RTF file type. Open the RTF
file you just created in Notepad. What you will see is a
load of RFT coding. However buried in this mess will be
your codes, ie VAR_PERSON_FULL_NAME. Copy everything from
the RTF file (without changing everything) into a clean
(blank) ASP page. Press home on your keyb to get right to
the start of the page and paste this:

<%Response.ContentType = "application/msword"%>

Do not add any spaces or other formatting after the
ContentType declaration above. You want to end up with
this:

<%Response.ContentType = "application/msword"%>{\rtf1\...

Now, do a search and find your VAR_PERSON_FULL_NAME code,
replace it with <%=Session("full_name")%>. Repeat for all
other codes. Run your ASP and you should generate your
Word document in the browser. Save and select Word as the
filetype and your done!

HTH,

Colin
-----Original Message-----
HI All

I just wonder if anyone has created a word document using ASP.
I am able to create a work document with ASP without any problem but what Iwant to do is slightly more than I know. I am sure someone where will knowhow to do the following.

We have a Word Template which is our standard contract type. I have somedata stored my access database record. I want to merge the two together.i.e. take the data from access and insert into various points in the worddocument. The points where I need to insert the data is definded byBookmarks in Word. This is how you can do it VBA but not sure if this ispossible in ASP.

In VBA I will write a statement like

With objWord
.Visible = True
.Documents.Add (WordTemplate)
.ActiveDocument.Bookmarks("GameDate").Select
.Selection.Text = (CStr(gamedate))
End With

Does anyone know the answer to the above issue or can you suggest analternative

thanks
.

Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: David Erickson | last post by:
I need to read some (about 15,000) word documents and add some wrappers around them for importing into a database. What is the best way to read a ..doc file in VB? I would like to save the...
4
by: jabailo | last post by:
I came across this article while researching a VB6 430 error: INFO: Considerations for Server-Side Automation of Office http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757 ...
1
by: mickeydisn | last post by:
Sub: C++ Word automation Extract text hello. I want extact text form a word document using a visual c++ programme. I have see a lot of documentation. and my analysis is that I must use a...
12
by: Cheval | last post by:
Has anyone had any problems with inter-office automation between MS Word and MS Access in Office 2003? I have recently installed office 2003 in a new folder and have left the older office 2000...
6
by: Colleyville Alan | last post by:
I have an application that has an Access table that stores the locations of slides in a Powerpoint file. This used to work fine when there were about 4 files and 200 slides. The database would...
0
by: mharris | last post by:
I need help with merging two Word documents into one through C# code. The problem isn't so much getting the documents put into one as it is maintaining the appropriate formatting, or rather...
5
by: Daniel Walzenbach | last post by:
Hi, I need to know how I could populate a word file from within ASP.NET and stream it out to some user (I can rely on all users have at least Word XP installed). The preferable solution would be...
2
by: William LaMartin | last post by:
I have created a program that allows for the automation of things in Word documents, like changing the values of DocVariables and the links to Excel Sheets. I did it using interoperoperatability,...
1
by: Robin Tucker | last post by:
Heres and interesting problem: I have a VB.NET program that creates reports via. Word Automation. This all works fine. What I want to do as part of this report generation process is to embed a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.