We want to implement a MailMerge service in OpenOffice. I have found a ABL code example of opening a writer document. I'm trying to implement a MailMerge service in ABL for OpenOffice.
Does anybody have experience with this and wants to share that with me?
Hinko van der Boom
Do you have your heart set on Openoffice documents? AlonB has created a really nice set of tools for creating DOCX files straight from ABL, which are really well suited to creating mailmerges.
On 24 July 2014 13:42, RWEBSTER
> RE: OpenOffice Mailmerge service
> Reply by RWEBSTER
> Do you have your heart set on Openoffice documents? AlonB has created a
> really nice set of tools for creating DOCX files straight from ABL, which
> are really well suited to creating mailmerges.
> Stop receiving emails on this subject.
> Flag this post as spam/abuse.
Rwebster : thank you for your info about creating docx files.
All our customers are using Word. But at this moment we have a large prospect who is using OpenOffice. And we don't want to lose that prospect. Thay is why we want to have a MailMerge in OpenOffice.
Flag this post as spam/abuse.
The first question I would ask is how complicated are the documents you will be creating (or plan to create in the future)? If it's simple letters, mail merge could definitely do the job. I think, as long as it's a single page, no repeating sections and only fields then you're good (although there are all kinds of tricks to create simple lists with some work).
BTW if you're planning to run the mail merge code in UNIX/Linux, you'll probably need to do it from another language besides progress if the code you looked at uses com-handles then it won't work on UNIX/Linux.
You could open .docx files in openoffice/libreoffice and there are also other converters but compatibility isn't perfect and in some cases it's far from it.
You could create the openoffice files directly (the xml files wrapped in a zip), I'd be happy to show you but it's alot of dirty work.
How soon do you need it? if it's a few month or so, maybe it's possible and in the meantime you could use the docx library. .docx and .odt files are very similar in essence so it's not an impossible thing to do.
BTW if you create the files in the free docxfactory project, it will be extremely fast. You could create a file in 0.02 seconds. Plus it has a ton of features like support for a extensive list of 80, 1D and 2D barcodes and you could also create Excel files, not just Word files.
Good luck and please share your findings.
My colleague Hinko is on holiday but I got it working. See source code below. The goal is to create simple letters. We need it in a few months or so but one of these days we need to confirm with our prospect that we can support OpenOffice.
There is one problem. If the datasource connects to a text file (e.g. CSV), the encoding should be ANSI and not UTF-8 otherwise OpenOffice does not detect the first column.
/* oo-mailmerge.p * Perform mailmerge in OpenOffice. * The source document already contains the data source 'test'. * Versions: * OpenEdge 11.3.2 (32-bits) * OpenOffice 4.1.0 * OS: Windows 7 Ultimate (32-bits) */ define variable sourcedoc as character no-undo initial 'C:/Temp/test-basis.odt'. define variable outputdir as character no-undo initial 'C:/Temp/'. define variable outputfile as character no-undo initial 'MERGED'. define variable datasource as character no-undo initial 'test'. define variable tablename as character no-undo initial 'test'. define variable hOO_application as com-handle no-undo. define variable hOO_mailmerge as com-handle no-undo. define variable Args as raw no-undo. session:appl-alert-box = true. /* Start OpenOffice application or get handle to running application. */ message 'Start OpenOffice'. create "com.sun.star.ServiceManager" hOO_application. /* Create mailmerge service. */ hOO_mailmerge = hOO_application:createinstance("com.sun.star.text.MailMerge"). /* Set mailmerge properties. * http://www.openoffice.org/api/docs/common/ref/com/sun/star/text/MailMerge.html */ message 'Set mailmerge properties'. assign hOO_mailmerge:DocumentURL = 'file:///' + sourcedoc /* source document (forward slashed only) */ hOO_mailmerge:DataSourceName = datasource /* name of data source (included in source document) */ hOO_mailmerge:CommandType = 0 /* 0 = table name, 1 = query name, 3 = SQL command */ hOO_mailmerge:Command = tablename /* name of table in data source */ hOO_mailmerge:OutputType = 2 /* 1 = printer, 2 = file, 3 = email */ hOO_mailmerge:OutputUrl = 'file:///' + outputdir /* output directory (forward slashes only) */ /* There are 2 ways to generate output: one single file or multiple individual files */ /* 1. Output to a single file */ hOO_mailmerge:FileNameFromColumn = false /* explicitly set output file name */ hOO_mailmerge:FileNamePrefix = outputfile /* output file name (excl. extension) */ hOO_mailmerge:SaveAsSingleFile = true /* save as single file */ /* 2. Output to multiple individual files hOO_mailmerge:FileNameFromColumn = true /* get file name from data source column */ hOO_mailmerge:FileNamePrefix = 'column1' /* name of data source column */ hOO_mailmerge:SaveAsSingleFile = false /* save as multiple files */ */ . /* Execute mailmerge. * The execute method takes a sequence (array) of com.sun.star.beans.NamedValue objects. * It is not clear how to create such a sequence in ABL, but fortunately this not required. * Instead, we feed an empty object of the RAW datatype to the execute method. * This causes the mailmerge service to use the default properties we set above. */ message 'Execute'. hOO_mailmerge:execute(Args). /* Dispose mailmerge service */ message 'Dispose'. hOO_mailmerge:dispose(). release object hOO_mailmerge no-error. release object hOO_application no-error.
Do you have more information on direct manipulation/creation of the OpenOffice ODT ZIP files? We are doing something similar with DOCX/XSLX files but we are getting complaints from some our users, so the Docxfactory seems to be the better solution. Thank you for that.