Am Dienstag, den 13.11.2007, 17:37 +0100 schrieb Willem Voogd:
> Hi,
Hi Willem,
> it's me again :)
>
> I'm still putting up a fight to get the mailmerge done programmatically.
> And again i find myself in the dark.
>
> When i set the OutputType property to MailMergeType.PRINT the file gets
> properly merged and printed, however when i set it to MailMergeType.FILE
> the file doesn't get merged before it gets saved.
> Is this a real bug or am i perhaps missing something that i have to do
> extra when choosing for OutputType MailMergeType.FILE?
I don't know exactly what the problem may be at your side, but I got
some code long ago on this list that was working flawlessly.
The code was designed to do a mail merge to file(s) by creating a
datasource, storing a doc with fields as template and merging the data
to an instance of this template as new document.
The merging sequence looks like this:
<snip>
public void doMerge() {
Object mmservice = null;
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;
}
// Get the XPropertySet interface of the mmservice object
XPropertySet oObjProps = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, mmservice);
try {
// Set up the properties for the MailMerge command
oObjProps.setPropertyValue("DataSourceName", mDataSourceName);
oObjProps.setPropertyValue("Command", mTableName);
oObjProps.setPropertyValue("CommandType",
new Integer(com.sun.star.sdb.CommandType.TABLE));
oObjProps.setPropertyValue("OutputType",
new Short(com.sun.star.text.MailMergeType.FILE));
oObjProps.setPropertyValue("DocumentURL", mFileURL);
} catch
</snip>
If anything fails I can pack up the complete bunch of files and send
them to you in private.
HTH,
Marc
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]