Hi,
I have to merge different documents. The first document has different headers and footers for even and odd pages. The second document has own headers and footers that are the same on each page. I copy the content of document 2 and paste it into document 1. Before pasting I create a new page with a section break and deactivate LinkToPrevious in this section so that the pages of document two remain their headers and footer.
The problem is that the new merged document has in document 1 the headers and footers that I expect. When the content of document 2 starts (the new section was inserted), it has on odd pages the headers and footers of itself and on even pages the LinkToPrevious
is active so that there are the headers and footers of the last section of document 1. What am I doing wrong? Why is LinkToPrevious active again on even pages?
Here's the relevant code:
InputFile.Content.Paragraphs(1).PageBreakBefore = False 'InputFile is document InputFile.Content.Copy InputFile.Close False Set InputFile = Nothing Set r = m_TargetDoc.Content 'r is range r.Collapse Direction:=wdCollapseEnd Set s = m_TargetDoc.Sections.Add(Range:=r, Start:=wdSectionBreakContinuous) 's is section s.PageSetup.SectionStart = wdSectionContinuous s.Headers(wdHeaderFooterFirstPage).LinkToPrevious = False s.Footers(wdHeaderFooterFirstPage).LinkToPrevious = False s.Headers(wdHeaderFooterFirstPage).Range.Text = "" s.Footers(wdHeaderFooterFirstPage).Range.Text = ""
s.Headers(wdHeaderFooterPrimary).LinkToPrevious = False
s.Footers(wdHeaderFooterPrimary).LinkToPrevious = False
s.Headers(wdHeaderFooterEvenPages).LinkToPrevious = False
s.Footers(wdHeaderFooterEvenPages).LinkToPrevious = False Set r = m_TargetDoc.Content r.Collapse Direction:=wdCollapseEnd r.Paste r.Paragraphs(1).PageBreakBefore = InsertPageBreak
m_TargetDoc is document 1 and InputFile is document 2.
Thanks a lot in advance,
M.H.