Merging Word Documents

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top