Forum at OOoForum.orgThe Forum
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Mailmerge from java program with OO 3.1

Post new topic   Reply to topic Forum Index -> Code Snippets
View previous topic :: View next topic  
Author Message

Joined: 18 Mar 2011
Posts: 1

PostPosted: Fri Mar 18, 2011 1:21 am    Post subject: Mailmerge from java program with OO 3.1 Reply with quote

I' have develop a jdbc driver that read from a custom data structure.Now I need to use
the mailmerge service to create documents from this data.
Using Writer mailmerge function all go well but when i try to use a java
program using UNO I've met this Exception

Caught UNO Exception: Mail merge failed. Sorry, no further information available.


 job.execute(new NamedValue[] {});

OpenOffice 3.1
O.S.: Windows XP service pack 2


        try {
            // Create an instance of the MailMerge service
            mmservice = mxMCF.createInstanceWithContext(
                "", mxComponentContext);
        catch (Exception e) {
            System.err.println("Error getting MailMerge service: " + e);
        try {
            XRowSet xRowSet = (XRowSet)UnoRuntime.queryInterface(XRowSet.class, mxMSF.createInstance(""));
            XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(
                XPropertySet.class, xRowSet);
            xProp.setPropertyValue("DataSourceName", DATASOURCENAME);
                new Integer(;

            // Get the XPropertySet interface of the mmservice object
            XPropertySet oObjProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, mmservice);
            oObjProps.setPropertyValue("ResultSet", xRowSet);
            oObjProps.setPropertyValue("DocumentURL", "file:///C:/");
            oObjProps.setPropertyValue("SaveAsSingleFile",new Boolean(false));

        // Get XJob interface from MailMerge service and call execute on it
        XJob job = (XJob) UnoRuntime.queryInterface(XJob.class, mmservice);

        try {
            job.execute(new NamedValue[] {});
        catch ( iae) {
            System.err.println("Caught IllegalArgumentException: " + iae);

Thanks for help.

PS: Sorry for my english.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Forum Index -> Code Snippets All times are GMT - 8 Hours
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2005 phpBB Group