Christian Jaspert
Christian Jaspert

Reputation: 1

preserve header when adding another worddocument without header

i use vba in wordfile A to add a word file B to the end of file A. File A has a header(Kopfzeile), file B does not have this. When B is added in the end of A, all the headers in A are gone, but what i want is that the header of A is also on the added content of B used code:

Set Doc_A = Documents.Open(path_A)
Doc_A.Range.InsertBreak (wdSectionBreakNextPage)
Selection.Collapse Direction:=wdCollapseEnd
Selection.InsertFile FileName:=Path_B

Upvotes: 0

Views: 73

Answers (1)

Timothy Rylatt
Timothy Rylatt

Reputation: 7860

You need to unlink the header(s) in the new section. For example:

Set Doc_A = Documents.Open(path_A)
Doc_A.Range.InsertBreak (wdSectionBreakNextPage)
With Doc_A.Sections.Last
    .Headers(wdHeaderFooterPrimary).LinkToPrevious = False
    .Range.Paragraphs.Last.Range.InsertFile FileName:=Path_B
End With

Upvotes: 1

Related Questions