473,396 Members | 1,853 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,396 software developers and data experts.

Imitating Mail Merge on server

I have an ASP intranet application that is required to produce Word
documents merged with data from a database. I originally looked at
automating Word's mail merge capabilities, but nixed that idea since I
learned it's not a good idea to try to automate Word on the server and I'd
rather not have to worry about whether or not the user has Word on their
machines.

I, instead, decided to have the Word templates saved as RTF files and to
write a parser/merger myself. This was going fine, although made me a
little nervous since Word produces such complicated RTF code, until we
decided that we were going to combine multiple templates into one final Word
document with, potentiall, different header and footers for each
section/template doc.

I'm having a problem figuring out how to get sections inserted into the
combined RTF doc, so I'm thinking perhaps I should rethink my solution...Can
anyone offer suggestions on how to produce database merged documents from
templates created by users on a Web server? We may have some budget, so
third-party tools would be welcome, as well.

Any suggestions would be greatly appreciated,
Diane Y.
Jul 19 '05 #1
1 1627
We do something similar in our app - it's based on the premise that at any
given moment we know which data (in this case, customers) is being worked
with. I'll give you a simple example:

--- letter ---

Dear #firstname#,

Thanks for your recent purchase. Sincerely,

#salespersonname#
Your Salesperson

--- end letter ---

--- table: LetterTokens --
tokenName varchar(255)
tokenSQL varchar(7000)

#firstname# SELECT cusFirstname FROM customers where cusNum = #cusnum#
#salespersonname# SELECT empFirstname FROM employees e INNER JOIN
customers c on e.employeeid = c.employeeid
where cusNum = #cusnum#

--- end table ---
The general process works like this:

First : open the tokens table into an array, adding an empty element on the
end for the eventual values, and concantenate each query together.
Second: run that query, using rs.open cxn, sqlString
Third: loop the array, plug in the current recordset value. set rs =
rs.nextRecordset, loop the array, and repeat until each recordset value has
been plugged in.
Fourth: open the letter, loop the array again, this time plugging the values
in with simple REPLACE statements.
Fifth: create a new file with the substitutions made and feed it to the
browser.

We have close to fifty tokens that we use in the application correspondence,
and there's no noticable lagtime. The only time there's a problem is if
someone puts in a token/query where the query hasn't been properly tested,
so the whole process fails. We've also recently added a token ~remover~
that replaces any unused sql tokens with a negative number so the query will
run, even if it doesn't return a value.

HTH,

- Wm
--
William Morris
Product Development, Seritas LLC
Kansas City, Missouri

"Diane Yocom" <di****************@seattle.gov> wrote in message
news:eS**************@TK2MSFTNGP10.phx.gbl...
I have an ASP intranet application that is required to produce Word
documents merged with data from a database. I originally looked at
automating Word's mail merge capabilities, but nixed that idea since I
learned it's not a good idea to try to automate Word on the server and I'd
rather not have to worry about whether or not the user has Word on their
machines.

I, instead, decided to have the Word templates saved as RTF files and to
write a parser/merger myself. This was going fine, although made me a
little nervous since Word produces such complicated RTF code, until we
decided that we were going to combine multiple templates into one final Word document with, potentiall, different header and footers for each
section/template doc.

I'm having a problem figuring out how to get sections inserted into the
combined RTF doc, so I'm thinking perhaps I should rethink my solution...Can anyone offer suggestions on how to produce database merged documents from
templates created by users on a Web server? We may have some budget, so
third-party tools would be welcome, as well.

Any suggestions would be greatly appreciated,
Diane Y.

Jul 19 '05 #2

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

Similar topics

0
by: Gajendra | last post by:
I am using C# , Web services and SQL server for mail merge. I am getting data from SQL server and putting all the data in work recordset and than I merge word data with mail merge template. This...
1
by: Lisa | last post by:
I have a query named QryDept where one of the fields is DeptID. The query is used for the data source of a mail merge letter. I would like to control which department is to get the mail merge...
8
by: Squirrel | last post by:
Hi everyone, I've created a mail merge Word doc. (using Office XP) , the data source is an Access query. Functionality I'm attempting to set up is: User sets a boolean field to true for...
3
by: Andy Davis | last post by:
I have set up a mail merge document in Word 2003 which gets its data from my Access 2000 database. I want to set up a button on a form that: 1. runs the query to provide the dat for the merge...
0
by: Ajay | last post by:
I using VB to mail merge the document to generate letters, I already wrote a program which merges the data from Oracle database and produces the letters on Windows NT/Microsoft Word2000. But the...
2
by: Mike Stephens | last post by:
A contact management application we previously developed for a customer now has a requirement to perform mail merging. Normally request like this would be very simple to solve, we were just point...
6
by: crealesmith | last post by:
Firstly, I have no problem with mail merging to Word, VB code for that works perfectly. On one mail merge I need to merge 15 fields of data that are from 3 seperate records. The 3 records are all...
7
by: =?Utf-8?B?QmFkaXM=?= | last post by:
Hi, I'm trying to follow a mail merging example in C#.Net that I got from: http://support.microsoft.com/default.aspx/kb/301659 and in one the methods: Word.Application wrdApp; Word._Document...
1
by: kayberrie | last post by:
I want to write a VBA mail merge code. I want to link the code/macro/dohicky to a nifty little button so it makes life easy. I think I can handle the button part, the code part - not so much. I know...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
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...
0
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,...

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.