Writer VBA MailMerge Query


I have a libreoffice writer document is there a way I can query the mailmerge output for a document and put them into a variable?

For example where the mailmerge is shown as on the document, how do i retrieve this value in VBA?


At first: VBA is a Microsofts BASIC-Environment. There won’t be any interfaces to OpenOffice or LibreOffice to use MailMerge.

With LibreOffice you have usually an odb-Database-file, wich handles the connection to your Data.
You may access this data-source directly in your BASIC-Macros.

I don’t think you can put a macro in a position to be involved during the actual MailMerge.


Thanks for your reply. Sorry I’m very new to Libre

I’m looking to access the data after the mailmerge has completed. If the mailmerge field was on a cell on a table on the writer document could VBA recover the result from referencing the cell. Or a bookmark?



Have not messed with this in years and not to a great extent either. So may not be able to answer all of your issues.

When you set up a mail merge document you have fields on the document which, in most cases, will bring in data from a data base. You gave an example in the question with <lastname>. Now when you execute the mail merge (can be done from a macro) output document(s) are created and the fields you have in the template will be replaced by the data taken from the database record(s). So <lastname> will become (example) Smith in the document. The field name is not present.

So the question you present cannot be answered much better than the comment noted by @Wanderer - get the data from the database.

Would also abandon the VBA direction you pose. Better to learn Star Basic or even Python.

As some further help, you may want to look at Open Office Macros Explained by Andrew Pitonyak. PDF here → OOME. Section 14.10 (about page 421) deals with Text Fields. You may find this of interest. There is a great deal of useful information in this document.