[Solved] ResultSet attribute of MailMerge object

Creating a macro - Writing a Script - Using the API

[Solved] ResultSet attribute of MailMerge object

Postby owlbrudder » Fri Apr 21, 2017 7:53 am

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   Expand viewCollapse view
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.1.2-2
Fedora 25 Linux x86_64
Core i7, 8Gb
owlbrudder
 
Posts: 69
Joined: Tue Nov 08, 2016 8:04 am

Re: ResultSet attibute of MailMerge object

Postby Villeroy » Fri Apr 21, 2017 11:53 am

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.

https://forum.openoffice.org/en/forum/v ... 96#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 16.04, OpenOffice 4.x & LibreOffice 5.x
User avatar
Villeroy
Volunteer
 
Posts: 23733
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: ResultSet attibute of MailMerge object

Postby owlbrudder » Sat Apr 22, 2017 5:41 am

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.1.2-2
Fedora 25 Linux x86_64
Core i7, 8Gb
owlbrudder
 
Posts: 69
Joined: Tue Nov 08, 2016 8:04 am

Re: ResultSet attibute of MailMerge object

Postby owlbrudder » Sat Apr 22, 2017 6:31 am

Villeroy, you have solved my problem! Many thanks.
Doug
LibreOffice Version: 5.3.1.2-2
Fedora 25 Linux x86_64
Core i7, 8Gb
owlbrudder
 
Posts: 69
Joined: Tue Nov 08, 2016 8:04 am

Re: ResultSet attibute of MailMerge object

Postby Villeroy » Sat Apr 22, 2017 11:33 am

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 16.04, OpenOffice 4.x & LibreOffice 5.x
User avatar
Villeroy
Volunteer
 
Posts: 23733
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: ResultSet attibute of MailMerge object

Postby owlbrudder » Sun Apr 23, 2017 6:18 am

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.1.2-2
Fedora 25 Linux x86_64
Core i7, 8Gb
owlbrudder
 
Posts: 69
Joined: Tue Nov 08, 2016 8:04 am

Re: [Solved] ResultSet attribute of MailMerge object

Postby Villeroy » Sun Apr 23, 2017 1:23 pm

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 16.04, OpenOffice 4.x & LibreOffice 5.x
User avatar
Villeroy
Volunteer
 
Posts: 23733
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Solved] ResultSet attribute of MailMerge object

Postby owlbrudder » Mon Apr 24, 2017 12:31 am

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.1.2-2
Fedora 25 Linux x86_64
Core i7, 8Gb
owlbrudder
 
Posts: 69
Joined: Tue Nov 08, 2016 8:04 am


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 9 guests