21
Sat, Dec
3 New Articles

The Way We Word: Merge That Mail!

Microsoft
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times
"This is Chris."

"Labels! I need labels! We're sending a mailing to Kentucky, and we need a label for every customer there!"

"Okeydoke!"

Ever have a conversation like that? I'll bet you have. But your customer master is on the iSeries, and you don't have a printer file set up to handle the new Avery label format, and all your printers are run from Client Access workstations, which means printing is a pain in the... well, you know what it's a pain in.

This is why integration can be so important. Microsoft's Office products offer some nice features and provide you with an easy way to format a document that isn't available directly on the iSeries. Wizards, like the downloadable Avery wizard, can help you format labels and include a merge data source--all in one step. While it isn't necessary to use the Avery wizard to format labels, it does make life a lot easier.

In this column, I'll walk you step by step through a mail merge using Microsoft Word (2000 in the example, but the procedure is the same for 97 and 2002). You'll set up a data source, create a merge file, and run your mail merge. In my next column, I'll walk you through automating this procedure with VBA so that your users can have some control over the selection criteria.

In this example, you'll send some form letters to customers in a specific ZIP code. The example assumes that you have Client Access Express and Microsoft Office

Holy Data Source!
To create a mail merge from an iSeries table, the easiest method to use is MSQuery, which is supplied with Microsoft Office. If you haven't installed MSQuery, you'll want to do so from the Office CD. (On 2000, if MSQuery isn't installed, you'll be prompted to insert the CD for installation.)

You'll also need to set up an ODBC data source that points to the library where your tables reside. On Windows 2000/NT, ODBC data sources are found under the control panel's administrative tools window. On 95/98, you'll find them in the control panel's main window. While it isn't necessary to do it this way, I like to create different data sources for each library. On the Client Access Express ODBC Setup dialog's server tab, I clear the library list and put the library name in the default library field. This gives me a way of limiting the list of files that link dialogs will present and controlling the contents of the list. See Figure 1 for a look at the setup dialog.

http://www.mcpressonline.com/articles/images/2002/mergetoword97V5b00.png

Figure 1: The ODBC Setup dialog box

I've found that the defaults for the other values in this dialog box work just fine, so I don't usually change them. However, I do recommend that you explore the ODBC Setup dialog and understand the various settings and their impacts. For example, you may want to set your DSN to Read-Only to prevent accidental modification of data.

Through Traffic, Merge Left!
With a data source defined, it's now possible to create a mail merge in Word.

Let's start with a new document. From the Tools menu, select the Mail Merge option. This brings up the Mail Merge Helper dialog shown in Figure 2. Click on the Create button and, for purposes of this example, choose Form Letters. A button labeled Edit will appear to the right of the Create button, but ignore that for now.

http://www.mcpressonline.com/articles/images/2002/mergetoword97V5b01.png

Figure 2: The Mail Merge Helper dialog box

Clicking on the Get Data button drops down another menu with several options. Choosing Open Data Source brings up the Open Data Source dialog box (see Figure 3). At the bottom is a checkbox labeled Select Method. Make sure this checkbox is checked, and click the MS Query button. (If you don't have MS Query installed, this is when you'll be prompted to insert your Office CD to install MS Query.)

http://www.mcpressonline.com/articles/images/2002/mergetoword97V5b02.png

Figure 3: The Open Data Source dialog box

Clicking on the MS Query button brings up MS Query with the Choose Data Source dialog box open (see Figure 4). This lets you select the data source you created earlier.

http://www.mcpressonline.com/articles/images/2002/mergetoword97V5b03.png

Figure 4: The Choose Data Source dialog box

Note that the Use the Query Wizard... checkbox is checked. This will bring up the wizard to build data selections. (If you want to use SQL, uncheck this box so that you can key in your own select statement.) When you press the OK button here, you get the next dialog, which shows you the wizard and asks you to select a file and fields.

Clicking on a table in the Choose Columns dialog (see Figure 5) shows you a list of the columns, or fields, in that table (or file, to us old guys). You can select all or just some of the fields.

http://www.mcpressonline.com/articles/images/2002/mergetoword97V5b04.png

Figure 5: The Choose Columns dialog box

For this example, select the customer number, name, and address fields from the customer master file. Then, click on the Next button to bring up the Filter Data dialog (Figure 6), which allows you to select the criteria that the query will use to return data.

http://www.mcpressonline.com/articles/images/2002/mergetoword97V5b05.png

Figure 6: The Filter Data dialog box

Here, you pick the field you want to filter on, choose the condition for selection from the drop-down list, and key in the criteria. Pressing the drop-down list on criteria (the rightmost field) will show all the values in the table for that field. This might take a few minutes. I think it's easier to just key in what you want. In this dialog, you can also choose multiple criteria and join them using "And" or "Or." For this example, I've chosen customers whose ZIP code is 85254, although I might want to choose customers whose ZIP code is like 85254 so that I can get those records that have the ZIP+4 (in that case, key in 85254%) .

Pressing Next on the Filter Data dialog takes us to the Sort Order dialog (see Figure 7). It isn't necessary to specify a sort order, but it's easy to do. Just choose the field (or fields) you want to sort on and specify ascending or descending.

http://www.mcpressonline.com/articles/images/2002/mergetoword97V5b06.png

Figure 7: Order your sorts!

Pressing Next here takes you to the final step in the data selection process, where you get the chance to bring the data on home!

The Finish dialog (Figure 8) offers the opportunity to return the data, view or edit the query, and save the query. If you think you'd re-use the query, you should save it. This will save future steps, as you can go straight to selection and choose a different set of records.

http://www.mcpressonline.com/articles/images/2002/mergetoword97V5b07.png

Figure 8: The last stop before returning data

When you click Finish, you are returned to Microsoft Word. At this point, Word will warn you that you have no fields in your primary document and offer you the chance to set some up. If you had selected Mailing Labels in the Mail Merge Helper dialog (Figure 2), this is where you would be prompted to choose the label type.

Clicking on Insert Merge Field on the Merge toolbar (upper left corner of Word) will bring up a list of the fields available from your query. For this example, select CNME (customer name), CAD1 and CAD2 (address lines 1 and 2), CAD3 (city), CSTE (state), and CZIP (ZIP code), as shown in Figure 9.

http://www.mcpressonline.com/articles/images/2002/mergetoword97V5b08.png

Figure 9: Choosing merge fields from Microsoft Word

When you put them in the document, they look like the image in Figure 10.
http://www.mcpressonline.com/articles/images/2002/mergetoword97V5b09.png

Figure 10: Merge fields in a document


In Figure 11, press the Merge to New Document button. The result will be one page per record for each record in the record set.

http://www.mcpressonline.com/articles/images/2002/mergetoword97V5b10.png

Figure 11: Merge to New Document on the toolbar


Figure 12 shows the first page of the merged document.

http://www.mcpressonline.com/articles/images/2002/mergetoword97V5b11.png

Figure 12: The results of the merge


As you can see, merging directly to Word involves a number of steps. However, the steps are easy and many of the choices can be saved. You really don't need to set up a data source more than once, and you can save queries you use repetitively.

The steps are all pretty sensible and orderly, and it doesn't take a lot to go through them, but the results can be pretty powerful. I encourage you to work with this as much as you can. In my next column, I'll show you how to use VBA to automate the merge function and the selection of data. This would give you a macro-based solution to present to end users so that they don't have to get into the mechanics of a query.

Chris Devous is the Director of IT Systems Development at The Antigua Group, Inc., a Peoria, Arizona, garment manufacturer. Chris has been in IT since '82 and lives Arizona with his wife, three children, a bird, two dogs, a cat, and various marine life forms. He can be reached by email at This email address is being protected from spambots. You need JavaScript enabled to view it.




BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: