473,757 Members | 7,200 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("Gam eDate").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 3841
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("Gam eDate").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.Cont entType = "applicatio n/msword"%>

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

<%Response.Cont entType = "applicatio n/msword"%>{\rtf1 \...

Now, do a search and find your VAR_PERSON_FULL _NAME code,
replace it with <%=Session("ful l_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("Gam eDate").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
15273
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 formatting as .RTF so it can be included. I can do this in Word VBA, but I would prefer to do it in straight VB (either VB6 or .Net). Thanks for any help on this.
4
2496
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 "Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, DCOM, and NT Services), because Office may exhibit unstable...
1
12087
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 "word automation". I have foud a lot of exemple to use it but I need your precious help to
12
5527
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 and office XP components installed. ie I have word/access/excel 2k/xp/2003 installed. I tried to do a usual access 2k to word 2k automation yet I get the error "Automation Error" "ClassFactory cannot supply requested class" when on late binding try...
6
3960
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 open all four PPT files at once, and would loop through queriers for ever client and create custom presentations. Now there are 8 files, nearly 500 slides and the computer is bogging down with trying to open them all at once. I know that Access...
0
6298
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 reformating, after the merge. This is a full description of my needs. I have a C# class library that creates two Crystal Reports, and then exports them to the harddrive as Word documents. One's orientation is landscape, the other is portrait. I then...
5
2527
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 to have a word template on the server which is populated in the asp.net application and then streamed out to the user. Also acceptable would be to open a template on the client's computer using automation and fill this file (if this is possible)....
2
11477
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, where, after adding a reference to Microsoft.Office.Core and a reference to Microsoft Word I declare objects as follows: Dim oWordApp As New Microsoft.Office.Interop.Word.Application, . Everything works fine on the development computer...
1
7638
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 graph/chart within the report, once again from VB.NET. I have chosen to use Excel.Chart.8. So, to embed I do this from VB.NET: Dim theNewShape As InlineShape = m_Document.InlineShapes.AddOLEObject (ClassType:="Excel.Chart", _
0
9489
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10072
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9906
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9885
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7286
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6562
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5172
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3829
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.