I need to do a simple mail merge in OpenOffice using C++, VBScript, VB.Net or C# via OLE or native API. Are there any good examples available?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I haven’t come up with a solution I’m really happy with but here are some notes:
Q. What is the OO API for mail merge?
A. http://api.openoffice.org/docs/common/ref/com/sun/star/text/MailMerge.html
Q. What support groups?
A. http://user.services.openoffice.org/en/forum/viewforum.php?f=20
Q. Sample code?
A. http://user.services.openoffice.org/en/forum/viewtopic.php?f=20&t=946&p=3778&hilit=mail+merge#p3778
http://user.services.openoffice.org/en/forum/viewtopic.php?f=20&t=8088&p=38017&hilit=mail+merge#p38017
Q. Any more examples?
A. file:///C:/Program%20Files/OpenOffice.org_2.4_SDK/examples/examples.html (comes with the SDK)
http://www.oooforum.org/forum/viewtopic.phtml?p=94970
Q. How do I build the examples?
A. e.g., for WriterDemo (C:\Program Files\OpenOffice.org_2.4_SDK\examples\CLI\VB.NET\WriterDemo)
Q. Does OO use the same separate data/document file for mail merge?
A. It allows for a range of data sources including csv files
Q. Does OO allow you to merge to all the different types (fax, email, new document printer)?
A. You can merge to a new document, print and email
Q. Can you add custom fields?
A. Yes
Q. How do you create a new document in VB.Net?
A.
Q. How do you save the document?
A.
Q. How do you Open the document?
A.
Q. How do you initiate a mail merge in VB.Net?
A.
Don’t know. This functionality is in the API reference but is missing from the IDL. We may be slightly screwed. Assuming the API was working, it looks like running a merge is fairly simple.
In VBScript:
Set objServiceManager = WScript.CreateObject(‘com.sun.star.ServiceManager’)
‘Now set up a new MailMerge using the settings extracted from that doc Set oMailMerge = objServiceManager.createInstance(‘com.sun.star.text.MailMerge’)
oMailMerge.DocumentURL = ‘file:///C:/Users/me/Desktop/OpenOffice Investigation/mail merged.odt’ oMailMerge.DataSourceName = ‘adds’ oMailMerge.CommandType = 0 ‘ http://api.openoffice.org/docs/common/ref/com/sun/star/text/MailMerge.html#CommandType oMailMerge.Command = ‘adds’ oMailMerge.OutputType = 2 ‘ http://api.openoffice.org/docs/common/ref/com/sun/star/text/MailMerge.html#OutputType oMailMerge.execute(Array())
In VB.Net (Option Strict Off)
The same thing but with Option Strict On (doesn’t work)