Page 1 of 1

[Solved] ResultSet attribute of MailMerge object

Posted: Fri Apr 21, 2017 7:53 am
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

Re: ResultSet attibute of MailMerge object

Posted: Fri Apr 21, 2017 11:53 am
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.

Re: ResultSet attibute of MailMerge object

Posted: Sat Apr 22, 2017 5:41 am
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

Re: ResultSet attibute of MailMerge object

Posted: Sat Apr 22, 2017 6:31 am
by owlbrudder
Villeroy, you have solved my problem! Many thanks.
Doug

Re: ResultSet attibute of MailMerge object

Posted: Sat Apr 22, 2017 11:33 am
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.

Re: ResultSet attibute of MailMerge object

Posted: Sun Apr 23, 2017 6:18 am
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

Re: [Solved] ResultSet attribute of MailMerge object

Posted: Sun Apr 23, 2017 1:23 pm
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.

Re: [Solved] ResultSet attribute of MailMerge object

Posted: Mon Apr 24, 2017 12:31 am
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