[Solved] Alphabetize names for mail merge

Writing a book, Automating Document Production - Discuss your special needs here
Post Reply
KeithSloan
Posts: 7
Joined: Wed Dec 07, 2022 5:03 pm

[Solved] Alphabetize names for mail merge

Post by KeithSloan »

I have the same problem but my address are stored in a database.

The mail merge seems to use the Primary Key which for me is a number that represents the order the records were created, where as I wish to have the Mail Merge use the addresses sorted by last name.

I have tried to create a different view with where my plan was to some how tell the mail merge to use the View rather than the database but I
failed on both counts. I did not find creating a view at all intuitive and could not see how it could be selected in the mail merge which just offers databases.
Last edited by MrProgrammer on Sat Dec 17, 2022 4:49 pm, edited 1 time in total.
Reason: Tagged ✓ [Solved] -- MrProgrammer, forum moderator
OpenOffice 4.1.8 with MacOS 12.4
User avatar
Hagar Delest
Moderator
Posts: 32670
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Alphabetizing a mailing list

Post by Hagar Delest »

Hi and welcome to the forum!

I have split your topic from Alphabetizing a mailing list, since it is not related to your current issue, that deals with mail merge.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
John_Ha
Volunteer
Posts: 9584
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Alphabetizing a mailing list for mail merge

Post by John_Ha »

Sorting the names in the database should be possible. The manual should say how to do it.

If you cannot sort in the database, brute force and ignorance suggests export the addresses to a .csv file. Import the .csv file into Calc. Sort in Calc. Use the spreadsheet as the source for the mail merge. Alternatively import them in the sorted order to a new database.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
KeithSloan
Posts: 7
Joined: Wed Dec 07, 2022 5:03 pm

Re: Alphabetizing a mailing list for mail merge

Post by KeithSloan »

John_Ha wrote: Wed Dec 07, 2022 6:16 pm Sorting the names in the database should be possible. The manual should say how to do it.

If you cannot sort in the database, brute force and ignorance suggests export the addresses to a .csv file. Import the .csv file into Calc. Sort in Calc. Use the spreadsheet as the source for the mail merge. Alternatively import them in the sorted order to a new database.
I can sort the names in the database but mail merge ignores and just uses the primary key as far as I can tell.

As to brute force approach, that is not very satisfactory as each time I add a new address I would have to go through that process.
OpenOffice 4.1.8 with MacOS 12.4
John_Ha
Volunteer
Posts: 9584
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Alphabetizing a mailing list for mail merge

Post by John_Ha »

Can you add a second key which is alphabetical.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
KeithSloan
Posts: 7
Joined: Wed Dec 07, 2022 5:03 pm

Re: Alphabetizing a mailing list for mail merge

Post by KeithSloan »

John_Ha wrote: Wed Dec 07, 2022 6:37 pm Can you add a second key which is alphabetical.
possibly but how do you tell mail merge to use that key?
OpenOffice 4.1.8 with MacOS 12.4
User avatar
MrProgrammer
Moderator
Posts: 4909
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Alphabetizing a mailing list for mail merge

Post by MrProgrammer »

KeithSloan wrote: Wed Dec 07, 2022 5:13 pm I wish to have the Mail Merge use the addresses sorted by last name.
Create a query which returns the data you want in the order you want. Use the query as the data source for the merge. I won't be able to help further until next week since I won't have access to my computer until then.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.6.3, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
KeithSloan
Posts: 7
Joined: Wed Dec 07, 2022 5:03 pm

Re: Alphabetizing a mailing list for mail merge

Post by KeithSloan »

MrProgrammer wrote: Wed Dec 07, 2022 7:04 pm
KeithSloan wrote: Wed Dec 07, 2022 5:13 pm I wish to have the Mail Merge use the addresses sorted by last name.
Create a query which returns the data you want in the order you want.
But how do I tell mail merge to use the query, it just offers me databases.
OpenOffice 4.1.8 with MacOS 12.4
KeithSloan
Posts: 7
Joined: Wed Dec 07, 2022 5:03 pm

Re: Alphabetizing a mailing list for mail merge

Post by KeithSloan »

KeithSloan wrote: Wed Dec 07, 2022 7:05 pm
MrProgrammer wrote: Wed Dec 07, 2022 7:04 pm
KeithSloan wrote: Wed Dec 07, 2022 5:13 pm I wish to have the Mail Merge use the addresses sorted by last name.
Create a query which returns the data you want in the order you want.
But how do I tell mail merge to use the query, it just offers me databases.
I would attach an screen shot image but it is 153Kb and the forum limit is 128Kb
OpenOffice 4.1.8 with MacOS 12.4
User avatar
Hagar Delest
Moderator
Posts: 32670
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Alphabetizing a mailing list for mail merge

Post by Hagar Delest »

Crop it or reduce its color depth.
Or use a 3rd party web site to share files.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Alphabetizing a mailing list for mail merge

Post by Villeroy »

menu:Edit>Exchange Database... lets you define the source table or query.
You can also sort the record set in the mail merge dialog: Print the serial letter, confirm serial letter, mark the sort column and click the sort button A-Z or Z-A.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
KeithSloan
Posts: 7
Joined: Wed Dec 07, 2022 5:03 pm

Re: Alphabetizing a mailing list for mail merge

Post by KeithSloan »

Villeroy wrote: Wed Dec 07, 2022 8:13 pm menu:Edit>Exchange Database... lets you define the source table or query.
You can also sort the record set in the mail merge dialog: Print the serial letter, confirm serial letter, mark the sort column and click the sort button A-Z or Z-A.
Where do I find print the serial letter?

The mail merge is creating a document with the labels filled out with from the database, when. I go to print, the labels are already in the order
as per the primary key.
OpenOffice 4.1.8 with MacOS 12.4
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Alphabetizing a mailing list for mail merge

Post by Villeroy »

When you print a document with mail merge fields, a message box pops up if you want to print a serial letter with options [Yes], [No], [Cancel]
[Yes] pops up another dialog where you can specify details about the records to be printed and about the ouput medium being a printer, a file or separate files for each record. Here you can filter and sort the record set.
[No] prints one copy of the document with place hodlers as visible on screen.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
KeithSloan
Posts: 7
Joined: Wed Dec 07, 2022 5:03 pm

Re: Alphabetizing a mailing list for mail merge

Post by KeithSloan »

Not seeing anything like that here.

From the labels.odt document I go Tools | Mail Merge Wizard

Then through a series of options and then it creates a new document filled out with info from the database. I can view and edit the new document.
If I print it does not perform any popups OpenOffice 4.1.13 on a Mac.
OpenOffice 4.1.8 with MacOS 12.4
User avatar
MrProgrammer
Moderator
Posts: 4909
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Alphabetizing a mailing list for mail merge

Post by MrProgrammer »

KeithSloan wrote: Wed Dec 07, 2022 5:13 pm The mail merge seems to use the Primary Key which for me is a number that represents the order the records were created, where as I wish to have the Mail Merge use the addresses sorted by last name.
I used File → New → Database → Create a new database to create a toy database in a Base document with a primary ID field, first name, and last name. I also used File → New → Labels to create labels in a Writer document with first name and last name Mail Merge fields. The database records are in the order they were entered, not in alphabetical order.

MrProgrammer wrote: Wed Dec 07, 2022 7:04 pm Create a query which returns the data you want in the order you want.
I created and saved this query for the database to retrieve the records in last name order. When I ask Base to display the data from the query, it shows the records in order by last name.
202212101747Q.gif
202212101747Q.gif (92.26 KiB) Viewed 5396 times

KeithSloan wrote: Wed Dec 07, 2022 7:05 pm But how do I tell mail merge to use the query, it just offers me databases.
I opened the label document, then used Edit → Exchange database to use the query that I saved in the Base document. Note the difference in the icons proceeding Addresses and Query_Addresses.
202212101747E.gif
202212101747E.gif (39.78 KiB) Viewed 5396 times

Villeroy wrote: Wed Dec 07, 2022 11:48 pm When you print a document with mail merge fields, a message box pops up if you want to print a serial letter with options
KeithSloan wrote: Wed Dec 07, 2022 11:57 pm Not seeing anything like that here. From the labels.odt document I go Tools | Mail Merge Wizard …
Your process is incorrect. I do not need the Tools → Mail Merge Wizard because I have already used the File → New → Labels wizard. After setting the label document to use the query, when I use File → Print on my Mac I get this dialog box. When I answer Yes and print the labels, they are in order by last name.
202212101747P.gif
202212101747P.gif (23.89 KiB) Viewed 5396 times


If you need any additional assistance attach your documents demonstrating the difficulty (remove confidential information then use Post Reply, not Quick Reply, and don't attach a picture instead of the document itself). I will not help further unless you attach. We will need you to attach a Base document and a Writer document (the label template). If your Base document points to an external database, you'll need to attach that data too.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.6.3, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
Post Reply