(Instructions of Aug 2015 using LibreOffice 4.4)
1. Use any spreadsheet as data source. Register it (ie make it available in the ‘Mail Merge Wizard’ of Writer (under Tools –>))
Use Writers ‘Address Data Source’ (File –> Wizards). Don’t use spaces in spreadsheet name. Make first line in spreadsheet the titles of the columns.
2. Prep a document. Insert mailmerge fields using: Insert–> Fields –> More fields –> Database –> Mail Merge Fields –> spreadhseet/sheet1 should be listed.
3. To suppress blank fields (per line), view ‘printing characters’ and change the carriage returns at end of lines for P (paragraphs), if not already. Then, with the cursor at the end of the relevant line: Insert–> fields–> more fields–>functions–>hidden paragraph]. In the ‘condition’ field in the dialogue: reference the spreadsheet column involved: use a ‘!’ (this means ‘NOT’) eg ![addresses1.Sheet1.Addressline2]
4. After this the Mail Merge Wizard brings you to step 8. Save the merged document as a single file. Upon ‘saving’ the merged document (behind the dialogue) seems to disappear. The saved merged file will be there, but there’s also another version ‘untitled1.odt’ etc lurking behind other things. I think this might be a glitch, but doesn’t really matter – just confusing.
5. my other blog post has a link to how to suppress a field placed within a line with other fields (eg no ‘salutation’ being listed in the spreadsheet).
As far as I know, OOo has no way to insert a database field only if it isn’t empty. Instead, I think the trick is to insert the [middlename] field always, and then insert a conditional space if the field is not empty. If the field is empty, then you don’t need the space.
You can try something like this:
1) View > Data Sources; select your table or query so that the data grid is filled in and active.
2) Insert > Fields > Other > Functions, Type: Conditional text
3) Drag the [middlename] column head from the data grid into the fields dialog, and drop it in the Condition entry. It should end up looking something like: [database.table.middlename].
4) Add text after the field to complete the condition: [database.table.middlename] neq “”
5) Enter a space in the “Then” entry. Leave the “Else” entry empty.
6) Click “Insert” and then “Close”
I think the above uses the same approach as for blank lines but replaces the blank paragraph with blank text. The slightly different approach used in the ‘condition’ field ie using neq “” instead of ! may be achieve the same end result, but have tested on this occasion – that’ll be Christmas letter time!