0211WG UsingMailMerge
0211WG UsingMailMerge
Chapter 11
Using Mail Merge
Form letters, mailing labels, and envelopes
OpenOffice.org
Copyright
This document is Copyright © 2005–2007 by its contributors as listed in the section titled
Authors. You can distribute it and/or modify it under the terms of either the GNU General
Public License, version 2 or later (http://www.gnu.org/licenses/gpl.html), or the Creative
Commons Attribution License, version 3.0 (http://creativecommons.org/licenses/by/3.0/) or
later.
All trademarks within this guide belong to their legitimate owners.
Authors
Iain Roberts
Peter Kupfer
Agnes Belzunce
Alan Madden
Jean Hollis Weber
Dick Detwiler
Peter Hillier-Brook
Feedback
Please direct any comments or suggestions about this document to:
[email protected]
Contents
Copyright.....................................................................................................................................i
Authors.........................................................................................................................................i
Feedback......................................................................................................................................i
Publication date and software version..........................................................................................i
What is mail merge?........................................................................................................................1
Creating the data source...................................................................................................................1
Registering a data source.................................................................................................................2
Creating a form letter.......................................................................................................................6
Printing mailing labels...................................................................................................................10
Editing a saved file of mailing labels........................................................................................15
Printing envelopes..........................................................................................................................16
Setting up envelopes for printing..............................................................................................16
Merging and printing the envelopes..........................................................................................20
Using the Mail Merge Wizard to create a form letter....................................................................21
Step 1: Select starting document...............................................................................................22
Step 2: Select document type....................................................................................................23
Step 3: Insert address block.......................................................................................................23
Selecting the data source (address list).................................................................................24
Selecting the address block..................................................................................................25
Matching the fields...............................................................................................................27
Step 4: Create salutation............................................................................................................28
Step 5: Adjust layout.................................................................................................................29
Step 6: Edit document and insert extra fields............................................................................30
Step 7: Personalize documents..................................................................................................32
Step 8: Save, print or send.........................................................................................................33
2) Select the appropriate type of external address book (in this case, Other external data
source). Click Next.
4) In the Data Source Properties dialog (Figure 5), select the Database type (in this case,
Spreadsheet). Click Next.
6) Click Finish.
7) In the following dialog (Figure 7), click Next. (Do not click Field Assignment.)
8) Name the file in the Location field. The default is ...\Addresses.odb; but you may
replace Addresses with another name if you wish. You may also change the name in
the “Address book name” field. In our example, the name “Points” was used for both.
You can create a form letter manually, which is the simplest and most comprehensive method
and is described here, or you can use the Mail Merge wizard as described in “Using the Mail
Merge Wizard to create a form letter” starting on page 21. If you elect to use the wizard, pay
close attention to its current (OOo V2.3) limitations, as identified within its description.
1) Create a new text document: File > New > Text Document, or open a pre-existing
form letter with File Open.
2) Display the registered data sources: View > Data sources (or press F4).
3) Find the data source that you wish to use for the form letter, in this case Points.
Expand the Points and Tables folders, and select Sheet1. The address data file is
displayed. (See Figure 9.)
5) Continue until you have composed the entire document. (See Figure 11 for an
example.) At this time you may wish to consider suppressing any blank lines that may
appear in the resulting letters. If not, skip ahead to Step 7.
8) In the Mail Merge dialog (Figure 13), you can choose to print all records or selected
records. To select records to be printed, use Ctrl+click to select individual records. To
select a block of records, select the first record in the block, scroll to the last record in
the block, and Shift+click on the last record.
TIP If the type of label you wish to use is not on the list, you need to use the Format tab
to define a new Brand and Type. This is beyond the scope of this document, but is
relatively simple to implement, given knowledge of the dimensions of the label .
Figure 15: Select Database, Table, label Brand, and label Type.
4) Click the dropdown arrow under Database field. Select the first field to be used in the
label (in this example, Title). Click the left arrow button to move this field to the
Label text area (Figure 16).
Figure 16: Move fields from Database field list to Label text area.
5) Continue adding fields and inserting desired punctuation, spaces, and line breaks until
the label is composed. Figure 17 shows the completed label.
6) Click New Document. You now have a new, single-page document containing a series
of frames, one for each label of the selected type and filled with the data source
address fields that you selected. Quite often some of the fields in your address data
source will be unused, leading to blank lines in your labels. If this is not important,
you can skip the next few paragraphs and go straight to Step 7, otherwise continue as
described here.
a) First ensure that the label frames are showing the field contents (data source
headings), rather than their underlying field names. If this is not the case, then
either press Ctrl+F9 or select View>Field Names to toggle the view.
b) Next, ensure that you can see non-printing characters, such as paragraph marks,
line breaks and so on. If these are not already visible, select View >
Nonprinting Characters from the menu bar, or press Ctrl+F10, or click on the
paragraph icon in the Standard toolbar.
You will now see that address field separation is created by line breaks , rather
than paragraphs . As the suppression of blank address fields depends on hiding
paragraphs, not lines, you need to replace line breaks with paragraphs as follows.
c) Click in the first label, at the end of the first data source address field. Press Delete
to remove the new line and then press Return (or the Enter key) to insert a
paragraph. Repeat this action for each data source address field.
If the line spacing in the first label is not satisfactory, you may wish to correct this
before proceeding, by modifying the paragraph style associated with the address.
Unless you have changed it, the address uses the Default style.
Caution The objective of step c) is to replace all line breaks at the end of data source address
fields with paragraphs. Sometimes the address data field may be longer than the
width of the label and will wrap to the next physical line: make sure that you are not
misled by this into deleting and replacing anything other than line break characters.
d) Click again at the end of the first paragraph to be suppressed and then select Insert
> Fields > Other. Select the Functions tab and then click on Hidden Paragraph in
the Type column. Now click in the Condition box and enter the details of the
condition that defines a blank address field. It has the general form of:
![Database.Table.Database field]
where the ‘!’ (NOT) character indicates the negative case and the square brackets
delineate the condition.
For example, in our Points database the condition to test if the Last Name field is
empty would be ![Points.Sheet1.Last Name] as illustrated in Figure 18.
To test for multiple conditions, use the operators AND and/or OR between the
conditional statements, for example:
![Points.Sheet1.Title]AND![Points.Sheet1.Last Name].
Click Insert, but do not close the dialog until all lines have been amended.
Caution The last paragraph of the label address block ends with a special field,
Next record:Database.Table (Next record:Points.Sheet1 in our example), and the
Hidden paragraph field MUST be inserted before this field. This can generally be
accomplished by clicking at the end of the paragraph and then using the Left Arrow
key once to skip back over it.
A clue that you omitted this action is the observation that some records have been
skipped and are missing from the final output.
8) In the Mail Merge dialog (Figure 20), you can choose to print all records or selected
records. To select records to be printed, use Ctrl+click to select individual records. To
select a block of records, select the first record in the block, scroll to the last record in
the block, and Shift+click on the last record.
Printing envelopes
Instead of printing mailing labels, you may wish to print directly onto envelopes. There are
two basic ways to create envelopes, one where the envelope is embedded within a letter,
generally as the first page (Insert in the Envelope dialog), and another where the envelope is
an independent document (New Doc. in the dialog). In each case the addressing data may be
manually entered, for example by copying and pasting from the letter with which it is
associated, or it may originate within an address data source.
This section assumes the use of an address data source and, for convenience, a free-standing
envelope.
The production of envelopes involves two steps, set-up and printing, as described in this
section.
Tip At this stage it is not possible to vary the dimensions of the frames that will hold the
Sender and Addressee information, but once the envelope has been created this will
become possible and you may wish to make some cosmetic adjustments.
5) Select the Envelope tab (Figure 23). Verify, add, or edit the information in the
Addressee and Sender boxes (Sender is the “from” on the envelope). You can use the
right-hand dropdown lists to select the database and table from which you can access
the Addressee information, in a similar fashion to that described for “Printing mailing
labels”, paragraphs 3, 4 and 5 on page 10. The similarity of the method with Figure
16 and Figure 17 will be clear.
6) When you have finished formatting, click either the New Doc. or Insert button to
finish. As might be expected, New Doc creates only the envelope template in a new
document, whereas Insert inserts the envelope into your current document as page 1.
If you don’t want to proceed with this envelope, click Cancel or press the Esc key.
You can also click Reset to remove your changes and return to the original settings
extant when the dialog opened.
6) Quite often some of the fields in your address data source will be unused, leading to
blank lines in your envelope Addressee area. If this is not important, you can skip the
next few paragraphs and go straight to “Merging and printing the envelopes” on page
20, otherwise continue as described here.
Tip The following procedure is very similar to that used for a similar purpose in the
section on printing mailing labels. It is reproduced here for purposes of clarity.
a) First ensure that the envelope is showing the field contents (data source headings),
rather than their underlying field names. If this is not the case, then either press
Ctrl+F9 or select View > Field Names to toggle the view.
b) Next, ensure that you can see non-printing characters, such as paragraph marks,
line breaks and so on. If these are not already visible, select View >
Nonprinting Characters from the menu bar, or press Ctrl+F10, or click on the
large paragraph icon in the Standard toolbar.
You will now see that address field separation is created by line breaks , rather
than paragraphs . As the suppression of blank address fields depends on hiding
paragraphs, not lines, you need to replace line breaks with paragraphs as follows.
c) Click at the end of the first data source address field. Press Delete to remove the
new line and then press Return (or the Enter key) to insert a paragraph. Repeat this
action for each data source address field.
If the line spacing in the Addressee area is not satisfactory, you may wish to
correct this before proceeding, by modifying the paragraph style associated with
the address. Unless you have changed it, the address uses the Default style.
Caution The objective of c) above is to replace all line breaks at the end of data source
address fields with paragraphs.
d) Click again at the end of the first paragraph to be suppressed and then select Insert
> Fields > Other. Select the Functions tab and then click on Hidden Paragraph in
the Type column. Now click in the Condition box and enter the details of the
condition that defines a blank address field. It has the general form of:
![Database.Table.Database field]
where the ‘!’ (NOT) character indicates the negative case and the square brackets
delineate the condition.
For example, in our Points database the condition to test if the Last Name field is
empty would be: ![Points.Sheet1.Last Name] as illustrated in Figure 18.
To test for multiple conditions, use the operators AND and/or OR between the
conditional statements, for example:
![Points.Sheet1.Title]AND![Points.Sheet1.Last Name].
Click Insert, but do not close the dialog until all lines have been amended.
e) Repeat for each paragraph to be conditionally suppressed, remembering to
advance the cursor to the end of the line in question before changing the last
element of the condition and Inserting the result.
2) The Mail Merge dialog (Figure 25) appears. As with form letters and mailing labels,
you can choose to print envelopes for one, several or all address records in the
database.
3) Make your selections and then click OK to print direct to the printer. If you wish to
check the envelopes before printing them, see Step 9) of “Creating a form letter” on
page 9 for instructions.
If the above limitations are not a hindrance to you, then open a new document with
File > New > Text Document and start the Mail Merge wizard using
Tools > Mail Merge Wizard. The wizard opens, as shown in Figure 26.
3) Select the address list and click OK to return to step 3 of the wizard. For this example,
the preceding steps are all you need to do. The wizard can also exclude certain records;
click Filter to choose them.
3) In the New Address Block dialog (Figure 31), you can add or delete address elements
using the arrow buttons on the left. To move elements around, use the arrow buttons
on the right. For example, to add an extra space between first and last names in Figure
31, click <Last Name> and then click the right arrow button.
3) When you have matched all the fields, click OK to return to step 3 of the wizard. Now,
when you use the arrow buttons to look at all the addresses, they should all look
correct. If not, go back and change anything you’re not happy with, before clicking
Next to move to step 4.
Note that you will not be able to continue until you have correctly matched all the
fields in your chosen address block. If you see <not available> in a field position it
indicates that the field in question is not correctly matched.
Note You do not need to tell OOo who is a male, because it assumes that all non-female
records are males.
If you do not select Insert Personalized Salutation, you can use a more general salutation
without referring to the recipient directly, such as “To whom it may concern”.
As in step 3, step 4 of the wizard has a preview pane at the bottom. You should check more
than one record to ensure that other records look the way you expect.
You need to perform another important task in this step. The wizard only inserts information
from the name and address fields, but you may wish to add additional data. In our example,
we want to tell each person how many points they had accumulated during the year; that
information is in the spreadsheet.
To do this:
1) Click Edit Document in step 6 of the wizard.
2) Select Insert > Fields > Other. The Fields dialog opens, as shown in Figure 37.
Note The Database selection lists the data source you selected in step 3. All the
information you need for the letter must be contained in that data source.
You probably want to save the starting (prototype) document and the merged document. To
do this, select Save starting document to reveal the Save starting document section
containing the Save starting document button. This button will be active only if the
document has not already been saved. Clicking on this button brings up the standard Save as
dialog. Once you have named and saved the document you return to the Step 8 dialog as
shown in Figure 40.
The merged document can now be saved by selection of Save merged document. This will
reveal the Save merged document settings section, from which you can select to save either
as one large file containing all the individual, generated letters or as a separate file for each
letter.
When you have saved the merged document, you can print the final letters now or later; and
you can still manually check and edit the letters if necessary. If you elect to print at this stage,
the dialog shown in Figure 41 appears; it should be self-explanatory.