我如何使用vb.net从多个单词docs创建一个单词doc

问题描述:

我有一个将报告输出为MS Word文档的应用程序。这是因为用户需要偶尔修改报告。我有一个报告的1页模板,报告可以是1页或50页,具体取决于数据。我可以正确地创建所有文档,但是当使用insert创建包含所有页面的一个文档时,它会失败。如何让它工作



文件名在表格中

I have an application that outputs reports as MS Word documents. This is because the user needs to occasionally modify the reports. I have a 1 page template for one of the reports and the report can be 1 page or 50 pages depending upon the data. I can create all the documents properly, but when using insert to create one document containing all the pages, it fails. How do I get this to work

the file names are in a table

    For lngZ = 1 To lngRecs
         strTempDoc = Tempset("FileName")
          If lngZ = 1 Then
             objWord.Documents.Add (strTempDoc) '  for the first document to be added use Documents.Add method
             Selection.MoveEnd Unit:=wdLine, Count:=1
          Else
               bX = InsertFile(strTempDoc, Range, ConfirmConversions, Link, Attachment)
               Selection.MoveEnd Unit:=wdLine, Count:=1
          End If
'          intGG = Instance.EndKey(Unit:=6)   '''' here
'            Selection.EndKey Unit:=wdStory, Extend:=wdMove
            Tempset.MoveNext
            If Tempset.EOF Then
                Exit For
            End If
    Next

请参阅:使用VB.NET将Word文档合并为单个文档的页面 [ ^ ]或者这里:合并Word文档 [ ^ ]
See this: Merge Word Documents As Pages Of A Single Document Using VB.NET[^] or here: Merge Word Documents[^]