如何使用 Vb.net 在 Openoffice 中进行邮件合并

发布于 2024-07-12 01:47:22 字数 224 浏览 12 评论 0原文

这是第五个问题,除此之外我没有得到专家的答复......

希望这次我能得到帮助。

我想使用 Vb.net 在 openoffice 中进行邮件合并,而且我对 openoffice 完全陌生。 我在网上搜索了一些帮助来了解如何在 vb.net 中使用 openoffice,但我得到的只是一半信息......所以你能帮助我并给我在 vb.net 中用于 openoffice 的邮件合并代码吗?

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

四叶草在未来唯美盛开 2024-07-19 01:47:22

好吧,我有数据库中的工作人员列表,并且有一个设施,如果他们想邮寄给所有或部分工作人员,那么他们就可以做到这一点。我现在已经使用 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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文