Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 37085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T14:29:43+00:00 2026-05-10T14:29:43+00:00

I need to do a simple mail merge in OpenOffice using C++, VBScript, VB.Net

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T14:29:44+00:00Added an answer on May 10, 2026 at 2:29 pm

    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)

      1. Add references to everything in here: C:\Program Files\OpenOffice.org 2.4\program\assembly
      2. That is cli_basetypes, cli_cppuhelper, cli_types, cli_ure
    • 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.

              Dim xContext As XComponentContext          xContext = Bootstrap.bootstrap()          Dim xFactory As XMultiServiceFactory         xFactory = DirectCast(xContext.getServiceManager(), _             XMultiServiceFactory)          'Create the Desktop         Dim xDesktop As unoidl.com.sun.star.frame.XDesktop         xDesktop = DirectCast(xFactory.createInstance('com.sun.star.frame.Desktop'), _             unoidl.com.sun.star.frame.XDesktop)          'Open a new empty writer document         Dim xComponentLoader As unoidl.com.sun.star.frame.XComponentLoader         xComponentLoader = DirectCast(xDesktop, unoidl.com.sun.star.frame.XComponentLoader)         Dim arProps() As unoidl.com.sun.star.beans.PropertyValue = _             New unoidl.com.sun.star.beans.PropertyValue() {}         Dim xComponent As unoidl.com.sun.star.lang.XComponent         xComponent = xComponentLoader.loadComponentFromURL( _             'private:factory/swriter', '_blank', 0, arProps)         Dim xTextDocument As unoidl.com.sun.star.text.XTextDocument         xTextDocument = DirectCast(xComponent, unoidl.com.sun.star.text.XTextDocument) 
    • Q. How do you save the document?

      A.

              Dim storer As unoidl.com.sun.star.frame.XStorable = DirectCast(xTextDocument, unoidl.com.sun.star.frame.XStorable)         arProps = New unoidl.com.sun.star.beans.PropertyValue() {}         storer.storeToURL('file:///C:/Users/me/Desktop/OpenOffice Investigation/saved doc.odt', arProps) 
    • Q. How do you Open the document?

      A.

              Dim xComponent As unoidl.com.sun.star.lang.XComponent         xComponent = xComponentLoader.loadComponentFromURL( _             'file:///C:/Users/me/Desktop/OpenOffice Investigation/saved doc.odt', '_blank', 0, arProps) 
    • Q. How do you initiate a mail merge in VB.Net?

      A.

      1. 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.

      2. 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())

      3. In VB.Net (Option Strict Off)

            Dim t_OOo As Type     t_OOo = Type.GetTypeFromProgID('com.sun.star.ServiceManager')     Dim objServiceManager As Object     objServiceManager = System.Activator.CreateInstance(t_OOo)      Dim oMailMerge As Object     oMailMerge = t_OOo.InvokeMember('createInstance', _                     BindingFlags.InvokeMethod, Nothing, _                     objServiceManager, New [Object]() {'com.sun.star.text.MailMerge'})      'Now set up a new MailMerge using the settings extracted from that doc     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(New [Object]() {}) 
      4. The same thing but with Option Strict On (doesn’t work)

            Dim t_OOo As Type     t_OOo = Type.GetTypeFromProgID('com.sun.star.ServiceManager')     Dim objServiceManager As Object     objServiceManager = System.Activator.CreateInstance(t_OOo)      Dim oMailMerge As Object     oMailMerge = t_OOo.InvokeMember('createInstance', _                     BindingFlags.InvokeMethod, Nothing, _                     objServiceManager, New [Object]() {'com.sun.star.text.MailMerge'})      'Now set up a new MailMerge using the settings extracted from that doc     oMailMerge.GetType().InvokeMember('DocumentURL', BindingFlags.SetProperty, Nothing, oMailMerge, New [Object]() {'file:///C:/Users/me/Desktop/OpenOffice Investigation/mail merged.odt'})     oMailMerge.GetType().InvokeMember('DataSourceName', BindingFlags.SetProperty, Nothing, oMailMerge, New [Object]() {'adds'})     oMailMerge.GetType().InvokeMember('CommandType', BindingFlags.SetProperty, Nothing, oMailMerge, New [Object]() {0})     oMailMerge.GetType().InvokeMember('Command', BindingFlags.SetProperty, Nothing, oMailMerge, New [Object]() {'adds'})     oMailMerge.GetType().InvokeMember('OutputType', BindingFlags.SetProperty, Nothing, oMailMerge, New [Object]() {2})     oMailMerge.GetType().InvokeMember('Execute', BindingFlags.InvokeMethod Or BindingFlags.IgnoreReturn, Nothing, oMailMerge, New [Object]() {}) ' this line fails with a type mismatch error 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 84k
  • Answers 84k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer $sql= "INSERT INTO customer(first_name,last_name,email,password,gender,city,dob,pin) VALUES('$first_name',". ($last_name?"'".$last_name."'":"NULL"). ", '$email_add','$password','$gender','$city','$DOB','$pin')"; This will… May 11, 2026 at 5:00 pm
  • Editorial Team
    Editorial Team added an answer What you look for is called "dependency injection". May 11, 2026 at 5:00 pm
  • Editorial Team
    Editorial Team added an answer .Net doesn't directly expose a lot of the normal HTML… May 11, 2026 at 5:00 pm

Related Questions

I am designing a system which will at some point require to send email
I have a postfix server listening and receiving all emails received at mywebsite.com Now
I am pretty new to php, but I am learning! I have a simple
Today I needed to parse some data out from an xlsx file (Office open

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.