Writer Guide

Chapter 11
Using Mail Merge
Form Letters, Mailing Labels, and EnvelopesCopyrightThis document is Copyright © 2011–2014 by the LibreOffice Documentation Team. Contributors
are listed below. You may distribute it and/or modify it under the terms of either the GNU General
Public License (http://www.gnu.org/licenses/gpl.html), version 3 or later, or the Creative Commons
Attribution License (http://creativecommons.org/licenses/by/4.0/), version 4.0 or later.
All trademarks within this guide belong to their legitimate owners.

Contributors
Ron Faile Jr.
Jean Hollis WeberJohn A Smith

Feedback
Please direct any comments or suggestions about this document to the Documentation Team’s
mailing list: documentation@global.libreoffice.org
Note: Everything you send to a mailing list, including your email address and any other personal
information that is written in the message, is publicly archived and cannot be deleted.

Acknowledgments
This chapter is adapted and updated from Chapter 11 of the OpenOffice.org 3.3 Writer Guide. The
contributors to that chapter are:Agnes BelzuncePeter Kupfer
Barbara M. Tobias

Dick Detwiler
Alan MaddenJean Hollis Weber

Peter Hillier-Brook
Iain Roberts
Michele Zarri

Publication date and software version
Published 19 July 2014. Based on LibreOffice 4.2.

Note for Mac users
Some keystrokes and menu items are different on a Mac from those used in Windows and Linux.
The table below gives some common substitutions for the instructions in this chapter. For a moredetailed list, see the application Help.
Windows or LinuxMac equivalent

EffectTools > Options
menu selection

LibreOffice > Preferences

Access setup options

Right-click

Control+click and/or right-click
depending on computer setup

Opens a context menu

Ctrl (Control)⌘ (Command)

Used with other keys

F5

Shift+⌘+F5

Opens the Navigator

F11

⌘+T

Opens the Styles and Formatting window

Documentation for LibreOffice is available at http://www.libreoffice.org/get-help/documentation

Contents
Copyright..............................................................................................................................2
Contributors................................................................................................................................. 2
Feedback..................................................................................................................................... 2
Acknowledgments........................................................................................................................ 2
Publication date and software version.........................................................................................2

Note for Mac users...............................................................................................................2
What is mail merge?............................................................................................................4
Creating and registering the data source..........................................................................4
Deregistering a data source................................................................................................7
Re-registering an existing data source.............................................................................7
Creating a form letter...........................................................................................................7
Editing merged documents.........................................................................................................11

Printing mailing labels.......................................................................................................11
Preparing for printing.................................................................................................................. 11
Removing blank lines from labels..............................................................................................14
Printing...................................................................................................................................... 15
Editing a saved file of mailing labels..........................................................................................15

Printing envelopes.............................................................................................................16
Setting up envelopes for printing................................................................................................16
Merging and printing the envelopes...........................................................................................19
Creating an envelope template..................................................................................................19

Using the Mail Merge Wizard to create a form letter......................................................20
Step 1: Select starting document...............................................................................................20
Step 2: Select document type....................................................................................................20
Step 3: Insert address block......................................................................................................21
Selecting the data source (address list).................................................................................22
Selecting the address block..................................................................................................22
Matching the fields................................................................................................................ 23
Step 4: Create salutation........................................................................................................... 24
Step 5: Adjust layout.................................................................................................................. 26
Step 6: Edit document and insert extra fields.............................................................................27
Step 7: Personalize documents.................................................................................................28
Step 8: Save, print or send........................................................................................................ 29

Using Mail Merge

3

What is mail merge?
LibreOffice Writer provides very useful features to create and print:• Multiple copies of a document to send to a list of different recipients (form letters)• Mailing labels• Envelopes
All these facilities, though different in application, are based around the concept of a registereddata source, from which is derived the variable address information necessary to their function.
This chapter describes the entire process. The steps include:
1) How to create and register a data source.
2) How to create and print form letters, mailing labels, and envelopes.
3) Optionally, how to save the output in an editable file instead of printing it directly.

Creating and registering the data source
A data source is a database containing the name and address records (and optionally otherinformation) from which a mailing list may be derived. Although you can create and print mailinglabels and envelopes without using a data source, in most cases using one is the best approach.
This chapter assumes that you are using a data source.
LibreOffice can access a wide variety of sources of data to create the database, including
spreadsheets, text files and databases such as MySQL, Adabas, and ODBC. If the information to
be used in the mail merge is currently in a format that LibreOffice cannot access directly, you needto convert it, for example by exporting it to a comma-separated values (CSV) file.
For the following example we start with a spreadsheet with the following column (field) headers:
Title, First Name, Last Name, Address, State/County, Country, Post Code, Sex, and Points. A
sample of data is shown in Figure 1.

Figure 1: Spreadsheet data example
After being created as described below, for a data source to be directly accessible from within a
Writer document, it must be registered. You only need to do this once; after that, the data source isavailable to all components of LibreOffice.
1) From within any Writer document, or from the LibreOffice Start Center, choose File >Wizards > Address Data Source.

4

Using Mail Merge

2) The choices on the first page of the wizard vary with your operating system. Select theappropriate type of external address book. In this example, it is Other external data
source. Click Next.

Figure 2: Select type of external address book3) On the next page of the Wizard, click the Settings button.

Figure 3: Starting the Settings part of the Wizard
4) In the Data Source Properties page, select the Database type. In our example, it is
Spreadsheet. Click Next.

Figure 4: Selecting the database type

Creating and registering the data source55) In the next dialog, click Browse and navigate to the spreadsheet that contains the address
information. Select the spreadsheet and click Open to return to this dialog. At this time you
may wish to test that the connection has been correctly established by clicking on the Test
Connection button (not shown in illustration).

Figure 5: Selecting the spreadsheet document
6) Click Finish.
7) On the following page, click Next. Because this is a spreadsheet, do not click Field
Assignment.

Figure 6: Because this is a spreadsheet, do not click Field Assignment8) A database file will be created. Name the file in the path in the Location field. The default isAddresses.odb; but you may replace Addresses with another name if you wish. You may
also change the name in the “Address book name” field. The name in this field is theregistered name, which LibreOffice will display in data source listings. In our example, thename “Points” was used for both.

Figure 7: Name the .odb file and the address book9) Click Finish. The data source is now registered.

6

Using Mail Merge

Deregistering a data source
To remove a registered data source from LibreOffice so it is no longer available for use, as forexample an obsolete address list, do the following:1) Open the Data sources window (by selecting View > Data Sources from the Menu bar, orby pressing F4, or by selecting the Data Sources icon on the Standard toolbar).
2) In the left pane, the Data source explorer, right-click a data source.
3) Select Registered databases from the context menu.
4) In the Registered databases dialog which opens, select the data source to be removed.
5) Click Delete, then click Yes in the confirmation box which opens.
6) Repeat steps 4) and 5) as required.
7) Click OK to close the Registered databases dialog.
This does not delete the database from your system. It can be registered again using the methods
outlined below.

Re-registering an existing data source
To re-register an existing database file of addresses do the following:1) Open the Data sources window (by selecting View > Data Sources from the Menu bar, orby pressing F4, or by selecting the Data Sources icon on the Standard toolbar).
2) In the left pane, the Data source explorer, right-click a data source.
3) Select Registered databases from the context menu.
4) In the Registered databases dialog which opens, click the New button
5) In the Create Database Link dialog which opens, click the Browse button and navigate to
the database file location and select it. Click the Open button to return to the Create
Database Link dialog.
6) Change the Registered name if required.
7) Click the OK button to exit this dialog.
8) Click the OK button to exit the Registered databases dialog.

Creating a form letter
Example: Sending a letter to your customer base
A mail order company organized a campaign to assign credit points to theircustomers according to the quantity of goods they buy during one year.
At the end of the year, they want to send a letter to each customer to show the totalof credit points collected.
You can create a form letter manually, which is the simplest and most comprehensive method andis 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 20. If you elect to use the wizard, pay close
attention to its current 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).

Creating a form letter7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.

Figure 8: Selecting the data source4) Now create or modify the form letter by typing in the text, punctuation, line breaks, and soon that will be present in all of the letters.
To add the mail-merge fields where needed (such as names and addresses), click in thefield heading and drag it to the appropriate point in the letter.
Note that address lines should be in individual paragraphs, not separated by line breaks asmight seem preferable. The reason for this will be made clear in the next step.

Figure 9: Dragging fields to the body of the form letter5) Continue until you have composed the entire document. At this time you may wish toconsider suppressing any blank lines that may appear in the resulting letters. If not, skip
ahead to Step 7.

8

Using Mail Merge

Figure 10: The completed form letter6) To suppress blank lines:a) Click at the end of the first paragraph to be suppressed if empty, and then choose
Insert > Fields > Other to display the Fields dialog.
b) Select the Functions tab and then click on Hidden Paragraph in the Type column.

Figure 11: Hidden paragraph insertion

Creating a form letter

9

c)

d)

Now click in the Condition box and enter the details of the condition that defines ablank address field. It has the general form of:![Database.Table.Database field]
where the ‘!’ (NOT) character indicates the negative case and the square brackets
indicate the condition.
For example, in our Points database the condition to test if the Last Name field isempty would be:![Points.Sheet1.Last Name] as illustrated in Figure 11.
To test for multiple conditions use the operators AND and/or OR between theconditional statements, for example:![Points.Sheet1.Title]AND![Points.Sheet1.Last Name]
Click Insert, but do not close the dialog until you have amended all the lines thatshould be suppressed.

7) The document is now ready to be printed.
a) Choose File > Print and respond with Yes in the message box.

Figure 12: Mail merge confirmation messageb) In the Mail Merge dialog (Figure 13), you can choose to print all records or selectedrecords. 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.
c) Click OK to send the letters directly to the printer. Or, you can save the letters to a filefor further editing or formatting; see “Editing merged documents” below.
d) If you have not saved the original, prototype form letter document (template) previously,
then you should do so now. Having a form letter template could greatly simplify thecreation of other form letters in the future and is highly recommended.

Figure 13: The Mail Merge dialog

10

Using Mail Merge

Editing merged documents
You may prefer to save the letters to a file, to allow for proofreading or some later formatting. To do
this:1) In the Mail Merge dialog (Figure 13), select File in the output section, instead of using thedefault Printer selection.
2) This changes the dialog to display the Save merged document section, where Save as
single document is preselected. You can choose to save each letter as an individual
document instead.

3) Click OK. In the Save as dialog, enter a file name for the saved letters and choose a folder
in which to save them. The letters will be saved consecutively as separate pages in the
single document, or numbered consecutively in individual files if saved as individual
documents.
You can now open the letters and edit them individually as you would edit any other document.

Printing mailing labels
Before beginning this process, note the brand and type of labels you intend to use.

Preparing for printing
To prepare mailing labels for printing:
1) Choose File > New > Labels.
2) On the Options tab, ensure that the Synchronize contents option is selected.
3) On the Labels tab (Figure 15), select the Database and Table. Select the Brand of labels
to be used, and then select the Type of label.
4) If you are unable to identify your label product in the list, then you can define the labels you
have. Select the User setting in the Type selection box. Click on the Format tab of theLabels dialog. The default settings are shown in Figure 16. Take a ruler and measure on
your labels those dimensions illustrated in Figure 14, and enter them into the respective
boxes on the left side.

Figure 14: Required information for label set-up

Printing mailing labels

11Figure 15: Select Database, Table, label Brand, and label Type

Figure 16: User label default settings5) You can now save your label template if you are likely to use it again. Click Save.
6) In the Save Label Format dialog that opens (Figure 17), enter names for your label Brand
and Type. Click OK.

12

Using Mail Merge

Figure 17: Name and save the label.
7) Click the Labels tab. Click the drop-down 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, as shown in Figure 18.

Figure 18: Move fields from Database field list to Label text area8) Continue adding fields and inserting desired punctuation, spaces, and line breaks until thelabel is composed. Figure 19 shows the completed label.

Figure 19: The completed label
Printing mailing labels

139) Click New Document. You now have a new, single-page document containing a series offrames, 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 beunused, leading to blank lines in your labels. If this is not important, go to “Printing” on page15; otherwise, continue with “Removing blank lines from labels”.

Removing blank lines from labels
1) 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 orchoose View > Field Names to toggle the view.
2) Next, ensure that you can see non-printing characters, such as paragraph marks, line
breaks and so on. If these are not already visible, choose View > Nonprinting Charactersfrom the Menu bar, or press Ctrl+F10, or click on the Nonprinting Characters icon (on the Standard toolbar.

)

You will now see that address field separation is created by line breaks ( ), rather thanparagraphs ( ). As the suppression of blank address fields depends on hiding paragraphs,
not lines, you need to replace line breaks with paragraphs as follows.
3) Click in the first label, at the end of the last data source address field in the first line of thelabel. Press Delete to remove the new line character and then press Return (or the Enterkey) to insert a paragraph marker. Repeat this action for each line in the address.
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.

CautionThe objective of step 3) 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 thatyou are not misled by this into deleting and replacing anything other than line
break characters.

4) Click again at the end of the first paragraph to be conditionally suppressed and thenchoose 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 thecondition 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 indicate
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 11.
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.
5) Repeat for each paragraph to be conditionally suppressed, remembering to advance thecursor to the end of the line in question before changing the last element of the condition
and Inserting the result.

14

Using Mail Merge

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. Thiscan generally be accomplished by clicking at the end of the paragraph and thenusing the Left Arrow key once to skip back over it.
A clue that you omitted this action is the observation that some records have beenskipped and are missing from the final output.

6) Remembering that we selected Synchronize contents
earlier, you should now be able to see a small window
containing a Synchronize Labels button. Click on thisbutton and the hidden paragraph fields are propagatedto all the labels in your document.
You now have a template suitable for future use with the same data source and type oflabel. If you wish to save it, use File > Templates > Save as Template to save it as anOpen Document Text Template (.ott) into the My Templates folder in the TemplatesManager dialog.

Printing
1) Choose File > Print. The message shown in Figure 12 appears. Click Yes to print.
2) In the Mail Merge dialog (Figure 13), you can choose to print all records or selectedrecords. To select records to be printed, use Ctrl+click to select individual records. To selecta 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.
3) Click OK to send the labels directly to the printer.
If you prefer to save the labels to a file, perhaps to allow some later editing such aschanging the typeface or paragraph format, then you should select File in the output
section of the Mail Merge dialog, rather than using the default Printer selection. Thischanges the dialog to highlight the Save merged document section, where Save as single
document is preselected.
In this case, clicking OK brings up the Save as dialog, where a file name can be entered forthe saved labels.
If you did not save the prototype label fields document (template) in Step 6 of theRemoving blank lines from documents paragraph, then you are prompted to do so now byanother Save as dialog.
In either case, whether printing or saving to file, despite there apparently being only one
page of labels, the printed or saved output will be expanded to include all of the selectedrecords from the data source.

Editing a saved file of mailing labels
To edit a saved file of mailing labels, open the saved label file in the normal way. You will beprompted to update all links. Choose No for the following reason: The first label on the page istermed the “Master Label” and all other labels are linked to it. If you update the links, then all labels
will end up containing the same data, which is probably not what you want.
You can edit individual records in the normal way, by highlighting and changing the font name, forexample.
However, you cannot edit all labels globally (for example, to change the font name for all records)by the technique of selecting the entire document. To achieve this result you have to edit theparagraph style associated with the label records as follows.
Printing mailing labels

151) Right-click any correctly spelled word in a label record. Select Edit Paragraph Style fromthe context menu. (Note: If you click on a misspelled word, a different menu appears.)
2) Then from the Paragraph Style dialog, you can make changes to the font name, the fontsize, the indents, and other attributes.

Printing envelopes
Instead of printing mailing labels, you may wish to print directly onto envelopes. By selecting Insert> Envelope from the Menu bar, you may select one of two methods for their production. The first iswhere the envelope is embedded within a letter, generally as the first page (Insert in the Envelope
dialog), and the second is where the envelope is an independent document (New Document in the
dialog). In each case the addressing data may be manually entered, for example by copying andpasting 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, setup and printing.

Setting up envelopes for printing
1) Choose Insert > Envelope from the Menu bar.
2) In the Envelope dialog, select the Format tab (Figure 20), where you can select theenvelope format to use. You can then arrange the layout of the envelope to suit yourrequirements, together with the character and paragraph attributes to be used in the
Sender and Addressee areas. These attributes are accessed using the Edit buttons to theright of the dialog, next to the word Format.

Figure 20: Envelope formatting dialog
16

Using Mail Merge

Note

If the list of envelope formats in the Size section of this dialog does not include thesize you need, choose User Defined (at the bottom of the list) and specify theenvelope size using the Width and Height boxes.

Tip

At this stage it is only possible to vary the position of the origin points (upper left
corners) of the frames that will hold the Sender and Addressee information, but
once the envelope has been created, full adjustment of size and position will
become possible and you may wish to make some cosmetic adjustments.

3) The next step is to select the Printer tab (Figure 21), from where you may choose theprinter you intend to use, its setup—for example, specification of the tray holding envelopes—and other printer-related options such as envelope orientation and shifting. You may
need to experiment with these settings to achieve the best results with your printer.

Figure 21: Choosing printer options for an envelope
4) Select the Envelope tab (Figure 22).
5) Choose whether or not to add Sender information to the envelope by selecting ordeselecting the Sender option. If wanted, edit the information in the Sender box (Sender is
the “from” on the envelope).
6) You now have the choice of creating the Addressee fields by dragging and dropping fromthe data source headings (as described in “Creating a form letter” on page 7, and inparticular in Figure 9) or using the facilities of the Envelope tab.
7) If you prefer dragging and dropping, then click New Document, drag your data source
headings into the Addressee area on your new envelope and skip to step 10), otherwise
continue with the next step.
8) Verify, add, or edit the information in the Addressee box. 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. The similarity of the method with Figure 18 and Figure 19 will be clear.

Printing envelopes

17Figure 22: Choosing addressee and sender information for envelopes
9) When you have finished formatting, click either the New Document or Insert button tofinish. As might be expected, New Document 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 canalso click Reset to remove your changes and return to the original settings extant when the
dialog opened.
You can now modify the placement of the frames containing the sender and addressee
information, or make further changes to the character and paragraph attributes (forexample, the font) or add a logo or other graphic to the envelope.

Tip

If you frequently print envelopes from the same database onto the same sizeenvelopes, at this point you may wish to create a template from this setup. See“Creating an envelope template” on page 19.

10) Quite often some of the fields in your address data source will be unused, leading to blanklines 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 19, otherwise
continue as described here.

Note
a)

18

The following procedure is very similar to that used for a similar purpose in thesection on printing mailing labels. It is reproduced here for ease of reference.

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 choose View > Field Names to toggle the view.

Using Mail Merge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, choose View > Nonprinting
Characters from the menu bar, or press Ctrl+F10, or click on the Nonprinting
Characters icon (

c)

d)

e)

) on 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.
Click at the end of the last data source address field in the first line of the envelope.
Press Delete to remove the new line character and then press Return (or the Enterkey) to insert a paragraph. Repeat this action for each line of the envelope.
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.
Click again at the end of the first paragraph to be conditionally suppressed and thenchoose 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 detailsof 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
indicate the condition.
For example, in our Points database the condition to test if the Last Name field isempty would be:![Points.Sheet1.Last Name] as illustrated in Figure 11.
To test for multiple conditions, use the operators AND and/or OR between theconditional 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.
Repeat for each paragraph to be conditionally suppressed, remembering to advancethe cursor to the end of the line in question before changing the last element of thecondition and Inserting the result.

Merging and printing the envelopes
To merge addresses and print the envelopes:
1) Choose File > Print. A message box (Figure 12) appears. Click Yes to print.
2) The Mail Merge dialog (Figure 13) appears. As with form letters and mailing labels, you canchoose 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. To check the envelopes
before printing them, see “Editing merged documents” on page 11 for instructions.

Creating an envelope template
When your envelope layout and fields are complete to your satisfaction, you can save the result asa template.
1) Choose File > Templates > Save As Template.
2) In the Template Manager dialog, select My Templates and click on Save.
3) Enter a name in the text input box and click OK to save the template.

Printing envelopes

19Using the Mail Merge Wizard to create a form letter
The manual method of creating a form letter described in “Creating a form letter” on page 7
provides the most control over the result and is therefore recommended. If you prefer to use theMail Merge wizard, the technique is described below.
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 23.

Step 1: Select starting document
The wizard gives various options to select your starting document:

•
•
•
•

Use the current document.
Create a new document.
Start with an existing document.
Start from a template.

For the purposes of this description, we assume that you opened a new text document. This will
ensure that all the steps in the wizard are fully explored, although with experience you may find it
more practical to use a draft you prepared earlier, which will allow for the skipping of some steps.
Select Use the current document and click Next.

Figure 23: Select starting document

Step 2: Select document typeThe wizard can produce letters or, if a Java Mail connection exists, email messages. In thisexample, we are producing a letter. Select Letter and click Next.

20

Using Mail Merge

Figure 24: Choose document type

Step 3: Insert address block
This is the most complex step in the wizard. In this step (Figure 25) you will do three things:
1) Tell the wizard which data source to use. The data source must be an existing file; in thisexample it is the “Points” spreadsheet created earlier.
2) Select the address block to use in the document. This means choosing which fields appear(for example, whether the country is included) and how they look.
3) Make sure that the fields all match correctly. This is very important. For example, the UK
English version of the wizard has a field called <Surname>. If your spreadsheet has acolumn called “Last Name”, you need to tell the wizard that <Surname> and “Last Name”
are equivalent. This is described in “Matching the fields” on page 23.

Figure 25: Insert address block

Using the Mail Merge Wizard to create a form letter

21

Selecting the data source (address list)
1) If the current address list, identified beneath the Select Different Address List button insection 1, is not the one you wish to use, click the button to open the Select Address List
dialog (Figure 26) for choosing a data source.
2) If you have not already created the address list, you may click Create to do so now. This
step will allow you to create a CSV (Comma Separated Values) file with a new list ofaddress records.
If you have an address list that is not registered in LibreOffice, but which you wish to use,click Add and select the file from the location in which it is saved.
In each of the above cases a new data source (ODB file) will be created and registered.
3) Select the address list and click OK to return to step 3 of the wizard. We retain “Points” as
our address book for this example. The wizard can also exclude certain records; click Filter
to choose them.

Figure 26: Select address list dialog

Selecting the address block
1) In section 2 (shown in Figure 25), select the address block to appear on the letter, define its
appearance, and choose the fields it contains. The main page gives two choices. Click
More to open the Select Address Block dialog for more choices.
2) The Select Address Block dialog (Figure 27) displays the original two blocks plus otherchoices for the format of the address block (you may need to scroll down to see all of the
choices). You can also optionally include or exclude the country (for example, only include
the country if it is not England) in the Address block settings. The formats provided are
relatively common, but they might not exactly match your preference. If this is the case,select the address block that is closest to what you want and click Edit, which opens theEdit Address Block dialog.

22

Using Mail Merge

Figure 27: Select address block3) In the Edit Address Block dialog, 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 forename and surname in Figure 28, click<Surname> and then click the right arrow button.

Figure 28: Edit address block

Matching the fields
Finally, it is time to match the wizard’s fields with the spreadsheet fields, so that items like
<Surname> and “Last Name” match correctly.
1) Look at section 3 of the wizard (shown in Figure 25 on page 21). The box at the bottom
displays one record at a time, using the address block format you specified. Use the rightand left arrow buttons below that address box to step through the addresses, checking thatthey display correctly. Do not assume that all the records display correctly, just because
one or two do. Check them all if you can, or at least a good proportion.
Using the Mail Merge Wizard to create a form letter232) If the addresses do not display correctly (and they probably will not right away), click Match
Fields.
3) The Match Fields dialog (Figure 29) has three columns:• Address Elements are the terms the wizard uses for each field, such as<Forename> and <Surname>.
• Use the Matches to Field column to select, for each address element, the field fromyour data source that matches it.
• The Preview column shows what will be shown for this field from the selected
address block, so you can double-check that the match is correct.
4) 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 inyour chosen address block. If you see <not yet matched> in a field position it indicates thatthe field in question is not correctly matched.

Figure 29: Match fields dialog
5) Notice the option for Suppress lines with empty fields in section 2 of Figure 25. Using
the Wizard, you do not have to create your own conditional suppression fields.

Step 4: Create salutation
It is possible to create just about any salutation you want in this step.
By selecting the This document should contain a salutation option, the General salutation list
box is enabled. Some general texts are available in the list box, or you can enter your own text,
such as Hello club member. A preview pane displays your choice.
24

Using Mail MergeBy also selecting the Insert personalized salutation option, further salutation constructs become
available.
You can, for example, use a different greeting for men and women. To do this, Writer must havesome way of knowing whether a person is male or female. In our spreadsheet (see Figure 1) we
had a column called Sex. In the section Address list field indicating a female recipient, set theField name to Sex and the Field value to F. The Male salutation is then printed for all men and theFemale salutation for all women.

Note

You do not need to tell LibreOffice who is a male, because it assumes that all nonfemale records are males.

If you do not have such a column in your spreadsheet, then you can leave the Field name andField value boxes empty and use the customized content of the Male list box for the salutation.

Figure 30: Create a salutation
As an example:
1) Click the New button alongside the Male list box. The Custom Salutation (Male Recipients)
dialog opens (see Figure 31).
2) Select Salutation in the Salutation elements listings.
3) Click the Add to salutation arrow button to add it to box 1.
4) Open the list box choices for box 2, select an appropriate greeting or type your own text
into the list box. Edit it as needed.
5) Select and move across Title from the Salutation elements listings into box 1.
6) Add a space and then move Last Name across.
7) Finally, move Punctuation Mark across and select the comma from the choices in box 2.
8) The construct is shown in the Preview box.
9) Carry out any final editing. Click OK.

Using the Mail Merge Wizard to create a form letter

25

Figure 31: Customizing the salutation
You can see that the <Title> field takes care of the gender aspect of the salutation. Using thismethod allows you to use gender neutral titles such as Doctor (Dr) and Reverend (Rev), or titles
such as Ms or Master.

Step 5: Adjust layout
In step 5, you can adjust the position of the address block and salutation on the page. You canplace the address block anywhere on the page. The salutation is always on the left, but you canmove it up and down the page. Use the buttons shown in Figure 32 to move the elements.

Figure 32: Adjust layout

26

Using Mail Merge

Step 6: Edit document and insert extra fields
In step 6 you have another opportunity to exclude particular recipients from the mail merge, as
shown in Figure 33.

Figure 33: Edit document
You can also edit the body of the document. If you started with a blank document, you can write
the whole letter in this step. Click Edit Document to shrink the wizard to a small window (Figure34) so you can easily edit the letter.

Figure 34: Minimized mail merge wizard
You need to perform another important task in this step. The wizard only inserts information fromthe name and address fields, but you may wish to add additional data. In our example, we want totell each person how many points they had accumulated during the year; that information is in the
database. To do this:1) Click Edit Document in step 6 of the wizard.
2) Choose Insert > Fields > Other. The Fields dialog opens.
3) Click the Database tab.
4) On the left hand side, select Mail merge fields.
5) Under Database selection find your data source (in this example, it is Points). Expand it to
see the fields.
6) Click the field you want to insert (Points), then click Insert to insert the field.
You can insert any number of fields any number of times into your mail merge document.
7) Click Close when you are done.

Note

The Database selection lists the data source you selected in step 3. All theinformation you need for the letter must be contained in that data source.

Using the Mail Merge Wizard to create a form letter

27

Figure 35: Insert mail merge fields dialog

Step 7: Personalize documents
This step creates all your letters, one per recipient.
Clicking the Edit individual Document button here is similar to step 6. The difference is that you
now edit a long file containing all of the letters, so you can make changes to a particular letter to
one person. In this step of the Mail Merge wizard, click Find to open a dialog that allows searches
within the document, perhaps for an individual addressee.

Figure 36: Personalize document
As with step 6, when editing the document, the wizard shrinks to a small window (Figure 34). Clickon this window to expand the wizard to its full size.

28

Using Mail Merge

Step 8: Save, print or send
You have now completed the mail merge process. The last step is to do something with it. In step8, you can save the original sample letter, save the merged document, print the letters right away
or, if you created email messages, send them.
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 theSave starting document button. This button will be active only if the document has not alreadybeen 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 38.

Figure 37: Step 8: Save, print or send
The merged document can now be saved by selecting 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.

Figure 38: Saving a merged document
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, thedialog shown in Figure 39 appears; it should be self-explanatory.

Using the Mail Merge Wizard to create a form letter

29

Figure 39: Printing the merged document

30

Using Mail Merge