views:

1129

answers:

2

Hey All,

Its 5th Question and apart of one i didnt get response from the experts....

Hope this time i will get the helping hand.

I want to do mailmerge in openoffice using Vb.net and i am totally new with openoffice. i searched on net for some help to understand how to use openoffice with vb.net but all i get is half info.....So can u plz help me and give me code for mailmerge in vb.net for openoffice.

A: 

Well i have list of workers in DB and there is this facility that if they want to mail to all or some of the workers then they can do it.I have completed this task using Microsoft Office now as a Add in we are providing the facility to perform the same task using Open Office.

What they have to do is just select the List of workers and click on a button and it will automate the mailmerge using the field of those workers data from DB. The Code of mine is as shown below

Public Sub OpenOfficeMail(ByVal StrFilter As String)
    Dim oSM ''Root object for accessing OpenOffice from VB
    Dim oDesk, oDoc As Object ''First objects from the API
    Dim arg(-1) ''Ignore it for the moment !

    ''Instanciate OOo : this line is mandatory with VB for OOo API
    oSM = CreateObject("com.sun.star.ServiceManager")
    ''Create the first and most important service
    oDesk = oSM.createInstance("com.sun.star.frame.Desktop")

    ''Create a new doc
    oDoc = oDesk.loadComponentFromURL("private:factory/swriter", "_blank", 0, arg)
    ''Close the doc
    oDoc.Close(True)
    oDoc = Nothing

    ''Open an existing doc (pay attention to the syntax for first argument)
    oDoc = oDesk.loadComponentFromURL("file:///C:\Users\Savan\Documents\1.odt", "_blank", 0, arg)
    Dim t_OOo As Type
    t_OOo = Type.GetTypeFromProgID("com.sun.star.ServiceManager")
    Dim objServiceManager As New Object
    objServiceManager = System.Activator.CreateInstance(t_OOo)
    Dim oMailMerge As New Object
    oMailMerge = t_OOo.InvokeMember("createInstance", Reflection.BindingFlags.InvokeMethod, Nothing, _
 objServiceManager, New [Object]() {"com.sun.star.text.MailMerge"}) 'com.sun.star.text.MailMerge"})
    oMailMerge.DocumentURL = "file:///C:\Users\Savan\Documents\1.odt"
    oMailMerge.DataSourceName = CreateSource(StrFilter)''Function that will return the datasource name which will be a text file's path
    oMailMerge.CommandType = 0
    oMailMerge.Command = "file:///C:\Mail.txt"
    oMailMerge.OutputType = 2
    oMailMerge.execute(New [Object]() {})**---->I am getting Error here**
End Sub
Savan Parmar
A: 

seems like here no one is having any idea about this problem or else they dont want to give any help coz this problem i uploaded long back and till now people just visit it but not a single reply on it......in such case where else to find the solution if you cant find ans in such Group of experts.

Savan Parmar
Nice attitude...
Eduardo Molteni
Um, either no one likes your attitude or no one knows the answer.
magnifico