我在周围看看这个应用程序是否可以完成。基本上,最终用户需要创建一堆从数据库填充的导出文档。如何将Word模板附加到VB.NET中的新文档中?
将会有大量文档模板(.dot),最终结果将是用户选择模板xy和z以包含文档,单击按钮并让应用程序创建一个新的Word文档,追加模板,以及然后用适当的数据填充模板。
它需要在Word中完成而不是类似Crystal Reports的原因是用户可能会在打印文档之前自定义一些字段,因为它可能因导出而异。
这可能通过VB.NET(VS 2010)来完成吗?
我认为这是,但我很难追踪解决方案。
或者还有更好的解决方案吗?
这里是我到目前为止(不太多,我知道)
Import Microsoft.Office.Interop
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim oWord As Word.Application
Dim oDoc As Word.Document
oWord = CreateObject("Word.Application")
oWord.Visible = False
oDoc = oWord.Documents.Add
'Open templates x.dot, y.dot, z.dot
'Append above templates to new document created
'Populate new document
oWord.Visible = True
End Sub
End Class
妈的,我很难相信它不能完成,哦,好吧。如何打开一个模板并将其复制并粘贴到一个新文档中,是否可以工作(并保留任何可寻址的字段,图像等)? – Tom 2010-05-05 14:31:42
我没有看到任何理由不起作用 - 尽管你不需要这样的'模板',但使用.doc也可以。 – stuartd 2010-05-06 16:11:48