Hello,
I'm writing a sub that will merge word docs without changing any formatting. It is working perfectly for the body of the paper, and the footer is the same in all of the documents so no issues there. The headers change in each document, all of them being of the primary type because each page of each document has the same header (they are basically chapters of a document that were written by different individuals and the client wants a copy of all of them together in a single docx file). I have the code look at the page and section count in each document and select the last n pages of the original doc, right after pasting the WholeStory in. I then make a Copy of the HeaderFooter, go to the combined doc to be added to, select the last n pages, unlink to previous all headers and copy paste in the header onto those n pages. In a 20 document merge, 15 of them are behaving exactly as I want them to. The puzzling thing is that some of the docs are expanding the header paste into the previous section even though it is outside the selected page range. I suspect it has something to do with my sections count but sections (long) isn't explained well in Microsoft's word VBA documentation and most of my VBA experience is in excel. One solution I tried was to have a continuous section break followed by a full section break after each chapter is added. I also tried reducing the number of selected pages in each pasted doc, and it changed nothing and resulted in a mess in the headers that were working. I also did step-throughs and message boxes to try to debug it. Do you have any ideas about what I did wrong here? Thanks! (Unfortunately I can't share the code due to my noob status).
Bookmarks