[Solved] ResultSet attribute of MailMerge object

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
owlbrudder
Posts: 93
Joined: Tue Nov 08, 2016 8:04 am

[Solved] ResultSet attribute of MailMerge object

Post by owlbrudder »

I am working with a mailmerge object and would like to have access to the current record each time a merge is undertaken. I have set up a listener OK, but have not found the resultset to be anything other than void. In the MailMerge documentation it says:

Code: Select all

ResultSet
::com::sun::star::sdbc::XResultSet ResultSet;
Description
provides access to a ::com::sun::star::sdbc::XResultSet of a ::com::sun::star::sdbc::ResultSet service.
Does anyone know whether this attribute supplies access to the recordset being used in the merge, or does it mean I have to provide the recordset for the merge to use? If the former, it seems to be what I want.

Any insights would be gratefully received.

Kind regards,
Doug
Last edited by owlbrudder on Sat Apr 22, 2017 6:32 am, edited 1 time in total.
LibreOffice Version: 5.3.3.0
Fedora 26 Linux x86_64
Core i7, 8Gb
User avatar
Villeroy
Volunteer
Posts: 31265
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: ResultSet attibute of MailMerge object

Post by Villeroy »

owlbrudder wrote:Does anyone know whether this attribute supplies access to the recordset being used in the merge, or does it mean I have to provide the recordset for the merge to use? If the former, it seems to be what I want.
This is what you should be able to find out by yourself.

viewtopic.php?f=20&t=83996#p390567 includes a simple listener example to intercept individual mail merge documents. If I remember correctly, all these document instances are temporary, however you can handle them as individual documents, manipulate them and save them separately. The macro produces the set up mail merge as a single document merge_biblio0.odt plus intercepted pdf copies.
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
owlbrudder
Posts: 93
Joined: Tue Nov 08, 2016 8:04 am

Re: ResultSet attibute of MailMerge object

Post by owlbrudder »

Thanks Villeroy - good advice as usual. I don't know why your reference didn't appear in my Google search - I obviously used the wrong search terms.

I've a feeling the email merge mm model was null when I examined it with MRI, but I'll hack your code and see what happens.

I'll post results here for future reference.

Thanks,
Doug
LibreOffice Version: 5.3.3.0
Fedora 26 Linux x86_64
Core i7, 8Gb
owlbrudder
Posts: 93
Joined: Tue Nov 08, 2016 8:04 am

Re: ResultSet attibute of MailMerge object

Post by owlbrudder »

Villeroy, you have solved my problem! Many thanks.
Doug
LibreOffice Version: 5.3.3.0
Fedora 26 Linux x86_64
Core i7, 8Gb
User avatar
Villeroy
Volunteer
Posts: 31265
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: ResultSet attibute of MailMerge object

Post by Villeroy »

owlbrudder wrote:Thanks Villeroy - good advice as usual. I don't know why your reference didn't appear in my Google search - I obviously used the wrong search terms.

I've a feeling the email merge mm model was null when I examined it with MRI, but I'll hack your code and see what happens.

I'll post results here for future reference.

Thanks,
Doug
I create my own MailMerge service because I could not find any such object for an already setup mail merge.
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
owlbrudder
Posts: 93
Joined: Tue Nov 08, 2016 8:04 am

Re: ResultSet attibute of MailMerge object

Post by owlbrudder »

Villeroy wrote:I could not find any such object for an already setup mail merge.
Yes, I am finding the MailMerge object frustratingly unclear to work with. It has a parameter slot for ResultSet, but I have been unable to see it other than as a void. Never mind: the solution you gave does 99% of what I want, so I am grateful.

Cheers,
Doug
LibreOffice Version: 5.3.3.0
Fedora 26 Linux x86_64
Core i7, 8Gb
User avatar
Villeroy
Volunteer
Posts: 31265
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Solved] ResultSet attribute of MailMerge object

Post by Villeroy »

If I remember correctly, I was able to set the ResultSet property of the MM object.
Instanciate a new MM object, connect to the database, open the result set and assign it to the MM.
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
owlbrudder
Posts: 93
Joined: Tue Nov 08, 2016 8:04 am

Re: [Solved] ResultSet attribute of MailMerge object

Post by owlbrudder »

Villeroy wrote:I was able to set the ResultSet property of the MM object.
Thanks for the tip. I tried using a SQL statement in place of a table, but that didn't supply data to the merge fields in my document. What you are suggesting is to create an MM object, separately create a recordset object containing the data I want to merge, then assign the recordset to the recordsource attribute of the MM object. That makes sense to me and I will give it a try, as it is what I was really looking for before, but was going about it the wrong way.

Again, many thanks.
Doug
LibreOffice Version: 5.3.3.0
Fedora 26 Linux x86_64
Core i7, 8Gb
Post Reply