Hide inline fields (not paragraphs!) in LibreOffice Writer mail merge

Hi everyone,

i am trying to create a mail merge letter, specifically adress lines from a spreadsheet. That works just fine, I have on problem though: I can’t find a way to hide empty fields - inline, NOT paragraphs.
Example:
<Academic-Title> <First-Name> <Last-Name>

So, what happens as a result is
a) For an entry WITH an academic title
“Dr. Michael Sampleman”
b) For an entry WITHOUT an academic title
" Janet Samplewoman"

Note the space before example b.

How can I hide an empty field, including the space between fields?

Thank you all so much for your help,
Julius

1 Like

Create two mail merge paragraphs. One like

  • <Academic-Title> <First-Name> <Last-Name> (1)
    (space between academic title and first name)

and the other like

  • <First-Name> <Last-Name> (2)
    (no space in the beginning, before first name)

Then set hidden paragraph with condition. Note: If hidden, the paragraph will not print and there will be no “empty line”.

How to hide paragraph (1)
<Academic-Title> == "" (will be shown if academic title exists)

How to hide paragraph (2)
<Academic-Title> NEQ "" (will be shown if academic title does not exist)

HTH

1 Like

A conditional space after the title is sufficient for me.

2025-12-05 08 37 38

2025-12-05 08 33 12

3 Likes

The better idea is the mortal enemy of the good idea. I think, you’re right.


I had another idea. If the source of the database is a Calc file you could add a space to each <academic-title> in the column or you copy the column and add the space there.
It’s quite easy, using regular expressions:
SEARCH .+ ↦ REPLACE &_ ( _ is symbol for space; empty cells are not affected)
In this case you do not need conditional effects.
.
Thanks for discussing the idea.

2 Likes

Thanks @PKG for the smart solution and @Grantler for starting the discussion.

Unfortunately, both solutions don’t seem to work. Maybe it’s a but due to the combination of an .ods spreadsheet and conditional functions?

I’ve tried both ways, but it seems, the document simply doesn’t update. If, for example, I create a test scenario with a conditional text:
Condition: [Kontakte-1.2.Alle.Titel] NEQ "" Then: Ja Else: Nein
It always shows Ja. No matter, if I select an entry, where the Title cell is empty, or not.

Well, I’ve now created the space within the spreadsheet itself as cheap workaround.

Thanks anyway!

2 Likes

It would be great if you could upload a test example demonstrating the problem.

Sure, but the database would have to be reconstructed from the .ods file.

Btw. I am working with LO 25.2.6.2.
Briefumschlag DIN lang.odt (22.1 KB)
Kontakte-1.3.ods (22.1 KB)

1 Like

@Knecker

It works for me with all other databases, just not with yours.

Briefumschlag DL -Ausdruck- - Kopie.odt (16,8 KB)

I’m afraid there’s a problem with the dot in the registered database name.
If I use the name “Kontakte” for registered database name, the conditional expression works.

4 Likes

@sokol92

:+1: :+1:

1 Like

Thank you so much, so, we do have a little bug at hand.
I shall file a report.

1 Like