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?
相关问题
- Sorting 3 numbers without branching [closed]
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- How to compile C++ code in GDB?
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)
You should take a look at Apache OpenOffice API. A project for creating an API for Open Office. A few languages they said to support are: C++, Java, Python, CLI, StarBasic, JavaScript and OLE.
Java Example of a mailmerge in OpenOffice.