wordpress hit counter
Re: How to copy header, footer and add page break before merge - WordprocessingML - Formats - OpenXML Developer

Re: How to copy header, footer and add page break before merge

Formats

Discussions about working with different Open XML Formats

How to copy header, footer and add page break before merge

  • rated by 0 users
  • This post has 1 Reply |
  • 1 Follower
  • Hi There

    I have VB.NET code merge word documents and it is working, but I need add page break before merge and also need header and footer as well on second page, the header and footer is the same, how can I do that?

     

    Thanks

    Tony

     

    Public Sub MergeWordDocuments(ByVal fileNames As List(Of String))

    If fileNames Is Nothing Then Exit Sub

    If fileNames.Count = 1 Then Exit Sub

    Dim altChunkId As String

    For i As Integer = 1 To fileNames.Count - 1

    altChunkId = "AltChunkId" & i.ToString

    Using myDoc As WordprocessingDocument = WordprocessingDocument.Open(fileNames(0), True)

    Dim mainPart As MainDocumentPart = myDoc.MainDocumentPart

    Dim chunk As AlternativeFormatImportPart = mainPart.AddAlternativeFormatImportPart(AlternativeFormatImportPartType.WordprocessingML, altChunkId)

    Using fs As FileStream = File.Open(fileNames(i), FileMode.Open)

    chunk.FeedData(fs)

    Dim altc As AltChunk = New AltChunk

    altc.Id = altChunkId mainPart.Document.Body.InsertAfter(altc, mainPart.Document.Body.Elements(Of Paragraph)().Last())

    mainPart.Document.Save()

    End Using

    End Using

    Next

    End Sub

  • BTW: I am using V2 of OPEN XML

Page 1 of 1 (2 items)