Home > Domino Tips > Developer > LotusScript > Putting an end to the frustration of mail merge
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

LOTUSSCRIPT

Putting an end to the frustration of mail merge


Chuck Connell
06.27.2005
Rating: -4.00- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


During the 15 years I've been involved with Lotus Notes, many people have asked me about mail merge from Notes to Microsoft Word. I usually give them a vague answer along the lines of, "Yeah, you can do it. I wrote some code a while ago that worked. But I can't find it now."

Now consider that one of the most common questions for the Microsoft support department is how to do mail merge, and it becomes clear that mail merge is a source of endless frustration for users. I hope that this article will solve the problem, once and for all, at least when passing data from Notes to Word. In this article, I'll first explain how to use the sample mail-merge application that I wrote, then describe the LotusScript code that does the work.

Notes output to Word is driven by a setup parameter that specifies the contents of the exported data. Within the Notes database, find the view named Settings, then open the parameter named Export - Mail Merge. The first line of the setup specifies the default name of the export file from Notes. The second line controls whether a header line is included in the export. (It usually is.) The remaining lines specify the names of the Notes fields that are included in the export.

To perform a data export, the Notes user selects any set of documents, pulls down the Action menu, and executes Mail Merge. You can try this yourself with the sample. First, create a directory named c:\mail-merge\ and use the view All Form1 to select some documents. When testing the export, you should use the default name for the export file, because the sample Word file is expecting that. After doing the export, examine the output file to verify that the selected data is present. Because there is a TAB character between each data field, the columns may not line up neatly when you look at the file on the screen, but the file is okay

The sample Word document named Customer Letter uses the Notes export file. The details of how mail merge works within Word vary, depending on the version of Word you have. A simple test is to use the next/last record buttons on the Word mail-merge toolbar. (The mail-merge toolbar should appear when you open the sample Word document. The next/last record buttons are left and right arrows.) You should see each "merged" letter in turn, one for each record exported from Notes.

The coding behind this sample uses two constructs: a simple agent, and the body of the code within a script library routine. The agent, named Mail Merge, contains only one line, which is a call to the script routine named ExportData within the library named MiscLib. The single parameter for the script call is the name of the user-definable setup parameter (Export - Mail Merge). The reason for this arrangement is so that you can easily create other instances of mail merge. You might want to export a different set of fields for certain Word documents, or to export a different set of Notes documents that contain different field names. You can do either without any new programming. Just create another setup parameter, say Export - Mail Merge 2, and another agent, say Mail Merge 2. The new agent is just like the current one, except that it includes the name of the new setup parameter in its call to the script routine.

The LotusScript routine (ExportData) includes generous comments and should be readable to those who want to see how it works. One way to possibly improve the code would be to include the field separation character (currently TAB) as one of the lines in the user-definable setup. I did not do so because TAB is so commonly used as a field separator that it seemed safe to leave that definition within the code. But if any reader wants to make this change, or finds a bug in the code, please let me know!

Chuck Connell is president of .CHC-3 Consulting, which helps organizations with all aspects of Domino and Notes. He can be reached at Connell@chc-3.com.

Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
LotusScript
Alternate version of @Command forwards subform via LotusScript
Process large arrays in Notes forms without undue coding or testing
How to use LotusScript to modify a Lotus Notes view selection
Display a custom message box using a LotusScript-generated button
Debug Lotus Notes documents using extracted data
Extracting attachments from a Lotus Notes rich-text field
Programmatically replace the design of Lotus Notes databases
Reading a binary field in an Oracle database with LotusScript
LotusScript equivalent of @Picklist for Lotus Notes
Launch large attachments within an email from a Notes database

LotusScript
Alternate version of @Command forwards subform via LotusScript
Process large arrays in Notes forms without undue coding or testing
How to use LotusScript to modify a Lotus Notes view selection
Display a custom message box using a LotusScript-generated button
Can I use LotusScript to merge cells in a Microsoft Word table?
Debug Lotus Notes documents using extracted data
Extracting attachments from a Lotus Notes rich-text field
Programmatically replace the design of Lotus Notes databases
Reading a binary field in an Oracle database with LotusScript
LotusScript equivalent of @Picklist for Lotus Notes

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.

HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 1999 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts