tomahawk73 Newbie

Joined: 18 Mar 2011 Posts: 1
|
Posted: Fri Mar 18, 2011 1:21 am Post subject: Mailmerge from java program with OO 3.1 |
|
|
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: com.sun.star.uno.Exception: Mail merge failed. Sorry, no further information available.
in
| Code: |
job.execute(new NamedValue[] {});
|
OpenOffice 3.1
O.S.: Windows XP service pack 2
| Code: |
try {
// Create an instance of the MailMerge service
mmservice = mxMCF.createInstanceWithContext(
"com.sun.star.text.MailMerge", mxComponentContext);
}
catch (Exception e) {
System.err.println("Error getting MailMerge service: " + e);
return;
}
try {
XRowSet xRowSet = (XRowSet)UnoRuntime.queryInterface(XRowSet.class, mxMSF.createInstance("com.sun.star.sdb.RowSet"));
XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(
XPropertySet.class, xRowSet);
xProp.setPropertyValue("User",<USER>);
xProp.setPropertyValue("Password",<password>);
xProp.setPropertyValue("DataSourceName", DATASOURCENAME);
xProp.setPropertyValue("CommandType",
new Integer(com.sun.star.sdb.CommandType.TABLE));
xProp.setPropertyValue("Command",TABLE_NAME);
xRowSet.execute();
// 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:/doc.ott");
oObjProps.setPropertyValue("OutputType",com.sun.star.text.MailMergeType.FILE);
oObjProps.setPropertyValue("SaveAsSingleFile",new Boolean(false));
oObjProps.setPropertyValue("OutputURL","file:///C:/files");
// 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 (com.sun.star.lang.IllegalArgumentException iae) {
System.err.println("Caught IllegalArgumentException: " + iae);
}
|
Thanks for help.
PS: Sorry for my english. |
|