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
Next
End Sub
BTW: I am using V2 of OPEN XML