第五个问题,除了一个我没有得到专家的答复....
希望这次我能伸出援助之手。
我想使用Vb.net在openoffice中进行mailmerge,而且我对openoffice是全新的。 我在网上搜索了一些帮助,以了解如何使用openbice与vb.net,但我得到的只是一半的信息.....所以,请你帮我,并给我在vb.net的mailmerge代码openoffice。
答案 0 :(得分:0)
我有数据库中的工作人员列表,如果他们想要邮寄给全部或部分工作人员,那么他们就可以做到这一点。我已经使用Microsoft Office完成了这项任务,现在我们正在添加提供使用Open Office执行相同任务的工具。
他们要做的只是选择工作人员列表并单击按钮,它将使用来自数据库的工作人员数据字段自动执行mailmerge。我的守则如下所示
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