2009-01-29 52 views
-2

第5题和一个分开的,我没有得到来自专家的响应....如何使用Vb.net

希望这个时间做邮件合并中OpenOffice的我将得到援助之手。

我想用Vb.net做邮件合并中OpenOffice和我与OpenOffice的全新的。 我搜索网上的一些帮助,了解如何使用OpenOffice与vb.net,但我得到的是半信息.....所以,你能帮帮我,给我的代码在vb.net OpenOffice的邮件合并。

+0

“mailmerge”是什么意思?而“PLZ给我代码”不会增加你回答的机会。 – dummy 2009-02-03 14:04:38

回答

0

嗯,我在DB工人的名单,有这个设施,如果他们想邮寄给职工的全部或部分,然后他们可以做它。我已经完成了使用Microsoft Office现在的添加在我们这个任务正在提供使用Open Office执行相同任务的工具。

,他们要做的只是选择工人的列表,点击一个按钮,它会使用来自DB这些工人的数据领域自动化邮件合并。我的代码如下所示

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