-2

Its 5th Question and apart of one I didn't 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 you please help me and give me code for mailmerge in vb.net for openoffice.

4

1 回答 1

0

好吧,我有 DB 中的工人名单,并且有这个设施,如果他们想邮寄给所有或部分工人,那么他们可以做到。我现在使用 Microsoft Office 作为插件完成了这项任务,我们正在提供设施使用 Open Office 执行相同的任务。

他们所要做的就是选择工作人员列表并单击一个按钮,它将使用数据库中这些工作人员数据的字段自动进行邮件合并。我的代码如下所示

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
于 2009-02-03T15:13:58.300 回答