E
Exformatics
Hello,
I'm merging several Word Documents into one document. I have one problem, I
can't preserve the headers of my documents. They all get the first documents
header.
Before merging a document I do the following:
With oSelection
.Collapse(Direction:=Word.WdCollapseDirection.wdCollapseEnd)
.InsertBreak(Word.WdBreakType.wdSectionBreakNextPage)
.Collapse(Word.WdCollapseDirection.wdCollapseEnd)
..Sections(1).Headers(Word.WdHeaderFooterIndex.wdHeaderFooterPrimary).LinkToPrevious = False
..Sections(1).Headers(Word.WdHeaderFooterIndex.wdHeaderFooterFirstPage).LinkToPrevious = False
..Sections(1).Headers(Word.WdHeaderFooterIndex.wdHeaderFooterEvenPages).LinkToPrevious = False
..Sections(1).Headers(Word.WdHeaderFooterIndex.wdHeaderFooterPrimary).PageNumbers.RestartNumberingAtSection = True
..Sections(1).Headers(Word.WdHeaderFooterIndex.wdHeaderFooterPrimary).PageNumbers.StartingNumber = 1
Then I use:
selection.InsertFile(file)
To insert the document.
The Pagenumbering is reset but the header is kept from the first inserted
document.
I would apreciate any help you can give in preserving my Headers.
/Martin
I'm merging several Word Documents into one document. I have one problem, I
can't preserve the headers of my documents. They all get the first documents
header.
Before merging a document I do the following:
With oSelection
.Collapse(Direction:=Word.WdCollapseDirection.wdCollapseEnd)
.InsertBreak(Word.WdBreakType.wdSectionBreakNextPage)
.Collapse(Word.WdCollapseDirection.wdCollapseEnd)
..Sections(1).Headers(Word.WdHeaderFooterIndex.wdHeaderFooterPrimary).LinkToPrevious = False
..Sections(1).Headers(Word.WdHeaderFooterIndex.wdHeaderFooterFirstPage).LinkToPrevious = False
..Sections(1).Headers(Word.WdHeaderFooterIndex.wdHeaderFooterEvenPages).LinkToPrevious = False
..Sections(1).Headers(Word.WdHeaderFooterIndex.wdHeaderFooterPrimary).PageNumbers.RestartNumberingAtSection = True
..Sections(1).Headers(Word.WdHeaderFooterIndex.wdHeaderFooterPrimary).PageNumbers.StartingNumber = 1
Then I use:
selection.InsertFile(file)
To insert the document.
The Pagenumbering is reset but the header is kept from the first inserted
document.
I would apreciate any help you can give in preserving my Headers.
/Martin